Skip to content
Advertisement

Inputting multiple 2D array elements at the same time

I am trying to create a program that will create an mxm grid using a 2D array. I want each of the elements within the array to be a “*”. The problem is that I don’t want to have to write a line of code to individually change each element within the grid. The m is going to be variable as the user is going to assign a value to it. This is the code I have so far:

JavaScript

If m =3 It would give the output:

JavaScript

However, I want the output to be:

JavaScript

Is there a way to do this in Java?

Advertisement

Answer

Of course if you never make an assignment

JavaScript

the values will still be their default, null.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement