This program compares two numbers in a 2*5 array which the user inputs and displays the largest number between the two. But I have some problem in understanding what [0] really does in int max = array[i][0]. I mean, shouldn't it be int max = array[i][j]? Because basically, what I understand from array[i][0] is that the numbers being input for the rows is being compared with the first element of the column since it's [0] but I would like some explanation how it actually works.
import java.util.*;
public class L2 {
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
System.out.println("Please enter 10 integers");
int array[][]= new int[2][5];
for(int i=0; i<array.length; i++){
int max= array[i][0];
for(int j=0; j<array[i].length; j++){
array[i][j]= input.nextInt();
if(max<array[i][j]){
max= array[i][j];
}
}
System.out.println("Maximum number in the row is "+ max);
System.out.println();
}
}
}