Let say i have this code:
this is outputpublic class ArrayDemo { public static void main (String[]args) { int [][] numbers = {{5,3,2},{7,5,3}}; int sum=0; int index1; int index2; for (index1 =0; index1< numbers.length; index1++) { for (index2 =0; index2< numbers[index1].length; index2++) { sum += numbers[index1][index2]; } } System.out.println("Sum: " + sum); System.out.println("Length: " + numbers.length); }}
output.PNG
What does the statement
mean?for (index2 =0; index2< numbers[index1].length; index2++)
And why does the length = 2?
Please i need an explanation in layman's terms.Thanks