I have a 2D array N*N , where N is from user input, and I want to prompt user to enter every row separately. I don’t know how to do it because N is not constant.
This is the code:
System.out.println("Enter number of nodes\n");
int V = scan.nextInt();
System.out.println("\nEnter matrix\n");
int[][] graph = new int[V][V];
for (int i = 0; i < V; i++)
for (int j = 0; j < V; j++)
graph[i][j] = scan.nextInt();
try