Answer:
The program in Java is as follows:
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Array size: ");
int n = input.nextInt();
int[][] myarray = new int[n][n];
for(int i =0;i<n;i++){
for(int j =0;j<n;j++){
myarray[i][j] = i * j; } }
for(int i =0;i<n;i++){
for(int j =0;j<n;j++){
System.out.print(myarray[i][j]+" "); }
System.out.println(); }
}}
Explanation:
This prompts the user for the array size
System.out.print("Array size: ");
This gets input for the array size
int n = input.nextInt();
This declares the array
int[][] myarray = new int[n][n];
This iterates through the rows
for(int i =0;i<n;i++){
This iterates through the columns
for(int j =0;j<n;j++){
This populates the array by multiplying the row and column
myarray[i][j] = i * j; } }
This iterates through the rows
for(int i =0;i<n;i++){
This iterates through the columns
for(int j =0;j<n;j++){
This prints each array element
System.out.print(myarray[i][j]+" "); }
This prints a new line at the end of each row
System.out.println(); }
}