Вы можете вызвать Arrays.toString () для каждой строки матрицы или Arrays.deepToString ().
import java.util.Arrays;
public class Test {
public static void main(String[] args) {
new Test().run();
}
private void run() {
int[] v = { 1, 2, 3 };
int[][] m = { { 1, 1, 1 }, { 2, 2, 2 }, { 3, 3, 3 } };
System.out.println("Printing the array: ");
System.out.println(Arrays.toString(v));
System.out.println("Printing the line addresses: ");
System.out.println(Arrays.toString(m));
System.out.println("Priting the matrix: ");
for (int[] l : m) {
System.out.println(Arrays.toString(l));
}
System.out.println("Priting the matrix (deepToString): ");
System.out.println(Arrays.deepToString(m));
}
}
Выход:
Printing the array:
[1, 2, 3]
Printing the line addresses:
[[I@3182f0db, [I@b92d342, [I@546b97fd]
Priting the matrix:
[1, 1, 1]
[2, 2, 2]
[3, 3, 3]
Priting the matrix (deepToString):
[[1, 1, 1], [2, 2, 2], [3, 3, 3]]