RosettaCodeData/Task/Greatest-element-of-a-list/Java/greatest-element-of-a-list-2.java
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

6 lines
244 B
Java

public static float max(float[] values) throws NoSuchElementException {
if (values.length == 0)
throw new NoSuchElementException();
Arrays.sort(values);//sorts the values in ascending order
return values[values.length-1];
}