I am a beginner in Java and I am trying to figure out why my method is not returning the largest value in the input array. My idea is the when the method is called, the for loops will search through every value of the array. Then it begins setting the first value as the largest value and any value that is greater than that value then becomes the largest value thereafter.
Any help is much appreciated!
public double displayLargest (double[][] l) {
for (int x=0; x < l.length-1; x++) {
for (int y=0; y < l[x].length; y++) {
double w = l[0][0];
if (w < l[x][y]) {
x++;
y++;
w = l[x][y];
maxValue = w;
}
}
}
System.out.println("The largest value in the array is: " + maxValue);
return maxValue;
}