There is a matrix, you need to display each element and also display its row and column.
public static void main(String[] args) { int[][] mat = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; int i = 0; int j; for (j = 0; j < mat.length; j++) { System.out.println("Element: " + mat[i][j] + "\n Ряд: " + i + "\n Столбец: " + j); i++; } } Displays only for 1, 5 and 9, since i and j are increased by 1, I do not know how to apply for each element.