daniel kidanee wrote:Hi,
So if I forget about the rows and columns, how would my
method know what to print?
for (int i = 0; i < ?; i++) {
Can you show me how you would do it for the first method for example
askInfo(int rows, int columns)? Remember you can't accept user input of rows
and columns inside the methods. Because the output would look different.
Thanks.
You can get length of array by writing
matrix.length.
Or even better. You can use enhanced for loop, so you don't even neet to know the length of the array!
One important thing to remember.
Java doesn't support matrices or multi-dimensional arrays.
In Java one can declare arrays of arrays.
So
matrix.length will give you numer of rows and
matrix[i].length will give you number of columns in i-th row (in case you decided not to use enhanced for loops).