0

how do we use for loop in multi dimensional arrays ? Please explain with a simple example thanks

14th Sep 2016, 5:24 PM
chirag shah
2 Respuestas
+ 2
http://code.sololearn.com/cSQemDqPlEz4 public class Program { public static void main(String[] args) { int[][][] arr = new int[][][] { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } }; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++) { for (int k = 0; k < arr[i][j].length; k++) { System.out.print(arr[i][j][k]); } System.out.println(); } System.out.println(); } } }
14th Sep 2016, 5:48 PM
Zen
Zen - avatar
+ 1
say if u hv two dimensional array .. then u can first for loop for row and second for loop for column .. and then u can add any work in loop . !! hope dat helps !!
16th Sep 2016, 8:28 AM
Bhushan Gaikwad
Bhushan Gaikwad - avatar