Integer [][] x = {{1,2,3},{4},{5,6}};
What is the best way to print the elements in stdout like this?
1
2
3
4
5
6
I have tried Arrays.deepToString(x) but doesnt output what I desire
Integer [][] x = {{1,2,3},{4},{5,6}};
What is the best way to print the elements in stdout like this?
1
2
3
4
5
6
I have tried Arrays.deepToString(x) but doesnt output what I desire
Try this :
public class MyClass {
public static void main(String args[]) {
Integer [][] x = {{1,2,3},{4},{5,6}};
for(Integer[] y : x) {
for(Integer i : y) {
System.out.println(i);
}
}
}
}
Output :
1
2
3
4
5
6
Here it is : https://ideone.com/9ywcjz