-
Returning Array Row
I'm doing a Java assignment in which I make a method that reads in a 2d Array of int's in the header as well as a integer as to which row to print"public static int[] getRow(int[][] myArr2D, int rowNum)" I am to print the specific row that corresponds with that Int, so if the values for the 2d Array where,
{7, -13, 22, 123},
{5, 9, 0, -17},
{44, 1, 22, 66},
{12, 13, 14, 22};
and the int rowNum was 3, it would return 44,1,22,66. I have been reading all over the web and cant seem to find any tutorials for this type of thing, I also have to do it the opposite way, Printing a column in another method, So if the colNum was 2 it would print -13,9,1,13 Any help would be great. Thank you
**Edit** Also i forgot to mention that the row im returning has to be a new 1d array.
-
Do you know how to use arrays?
I suggest you read up on them.
-
To clarify something that usually confuses new people when working with 2d arrays I offer this.
A 2d array is merely a 1 d array where each element is another array.