By prakharpandey04
public class TwoDimensionalArray {
public static void main(String[] args) {
int rows = 5;
int columns = 5;
int[][] array = new int[rows][columns];
int value = 1;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
array[i][j] = value;
value++;
}
}
System.out.println("The 2-D array is: ");
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
System.out.print(array[i][j] + " ");
}
System.out.println();
}
}
}