When trying to execute the following snippet:
int[] vetor = {1, 2, 3, 4, 5, 6};
System.out.println(Arrays.toString(vetor));
The array is normally displayed as [1, 2, 3, 4, 5, 6]
but if I try with a two-dimensional array, as follows:
int[][] matriz = {{1, 2, 3, 4, 5, 6}, {8, 10, 12, 14}};
System.out.println(Arrays.toString(matriz));
The result is [[I@7852e922, [I@4e25154f]
and the array values are not displayed.
Is there a way to display a direct two-dimensional array in System.out.println
without having to loop or overwrite methods, as occurred in code with the simple array?