Masa Egart Masa Egart - 5 months ago 31
Java Question

User input numbers into a 2 dimensional array in java

I'm having trouble with user input in java, hope anyone can help :)
The user declares how big the 2d array will be(number d is the side of the square array), then inputs a number "n", which tells the program how many inputs of numbers there will be, and then needs to input these numbers (eg. if n=4, the input must be sth like : 5 17 3 20.
I have already written the same thing for a single row array

for(i=0;i<=n;i++) {

but am having trouble doing basically the same for the 2d array.
Any ideas?


Use two nested loops and index like arr[i][j]