for (int i=1; i<numbers.length;i++)
result=numbers[i];
this makes result
the last element of the array, not the greatest one…
You probably wanted
for (int i=1; i<numbers.length;i++)
result = Math.max(numbers[i], result);
for (int i=1; i<numbers.length;i++)
result=numbers[i];
this makes result
the last element of the array, not the greatest one…
You probably wanted
for (int i=1; i<numbers.length;i++)
result = Math.max(numbers[i], result);