You are working on a software project where you need to display a square matrix of integers to the command-line in a grid-like format. The numbers in this matrix range from 1 to n*n, where 'n' represents the number of rows/columns. The display should be such that each number is separated from the next by a space and each row of numbers is on a new line. Currently, the code you have does not display the matrix as per your requirements. Your task is to reorder the provided lines of the code so that it correctly displays the matrix.
Multidimensional array
Sorting a square matrix display on the command-line
Report a typo
Reorder lines using drag or arrows. Adjust indentation with left buttons
}
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
}
System.out.print(matrix[i][j] + " ");
public static void main(String[] args) {
}
System.out.println();
public class Main {
}
int[][] matrix = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.