+ 2
how to loop multi array in java?
thanks
3 Respuestas
+ 4
public class Program {
public static void main(String[] args) {
int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} };
for(int x=0; x<myArr.length; x++){
for(int y=0; y<myArr[x].length; y++)
System.out.print(myArr[x][y] +" ");
System.out.println();
}
}
}
+ 3
thank you guys <3
+ 1
Or you can use the For each or enhanced for loop like this:
for(int[] subarray : myArr)
{
for (int element : subarray)
{
System.out.print(element);
}
System.out.println();
}