0

Why we cannot put' , ' after the bracket {2,3,4} and {2,3}?

int[][][] test = { { {1, -2, 3}, {2, 3, 4} }, { {-4, -5, 6, 9}, {1}, {2, 3} } }; // for..each loop to iterate through elements of 3d array for (int[][] array2D: test) { for (int[] array1D: array2D) { for(int item: array1D) { System.out.println(item); } } } } } But in 2D array, they put ',' before it end

2nd Jan 2023, 5:47 PM
Aenul
Aenul - avatar
2 Réponses
+ 2
Putting camma there means "still there another array left. But for your, those are the last arrays {} so you should not put for last one...
2nd Jan 2023, 5:55 PM
Jayakrishna 🇮🇳
+ 1
Ouhh I understand. Thanks!
2nd Jan 2023, 5:58 PM
Aenul
Aenul - avatar