2D ARRAY MATRIX JAVA
import java.util.*;
public class Main {
public static void main(String[] args) {
int i, j;
// Initialize the 2D array directly
int a[][] =
{
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};
System.out.println("Data of 2D array in matrix form:");
// Loop through the rows
for (i = 0; i < 3; i++) {
// Loop through the columns
for (j = 0; j < 3; j++) {
System.out.print(a[i][j] + " "); // Print with a space
}
System.out.println(); // Move to the next line after each row
}
}
}