public static int mode ( int [ ] values ) { if ( values . length == 0 ) throw new IllegalArgumentException ( "No mode in an empty array" ) ; Counter < Integer > c = new ObjectCounter < Integer > ( ) ; for ( int i : values ) c . count ( i ) ; return c . max ( ) ; }
Returns the mode value of the array of ints