public static int maxInArray ( int [ ] values ) { if ( ( values == null ) || ( values . length == 0 ) ) { throw new IllegalArgumentException ( "Cannot find the max of a null or empty array." ) ; } int max = values [ 0 ] ; for ( int value : values ) { max = ( max < value ) ? value : max ; } return max ; }
Returns the maximum value in an array of integers .