Issue
I want the output to look like:
[1, 1, 1, 1]
[1, 1, 1, 1]
[1, 1, 1, 1]
[1, 1, 1, 1]
My code right now outputs:
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
for (int j = 0; j < Matrix.length; j++) {
for (int k = 0; k < Matrix[0].length; k++) {
System.out.print(Matrix[j][k] + " ");
}
System.out.print("\n");
}
How can I make this work?
Solution
Try this
for (int[] row : Matrix)
System.out.println(Arrays.toString(row));
Answered By - user4910279
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.