[Solved] Why does it return max for 2.0 in java? [closed]


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);

1

solved Why does it return max for 2.0 in java? [closed]