Greatest element of a list: Difference between revisions

(→‎{{header|Vim Script}}: Fix indentation (tabs → spaces))
Line 2,423:
 
=={{header|Java}}==
<syntaxhighlight lang="java">
int max(int[] values) {
int max = values[0];
for (int value : values)
if (max < value) max = value;
return max;
}
</syntaxhighlight>
<br />
The first function works with arrays of floats. Replace with arrays of double, int, or other primitive data type.
<syntaxhighlight lang="java">public static float max(float[] values) throws NoSuchElementException {
118

edits