Results 1 to 3 of 3
  1. #1
    Zocheyado is offline Member
    Join Date
    Apr 2011
    Rep Power

    Default 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.
    Last edited by Zocheyado; 04-14-2011 at 08:34 PM.

  2. #2
    ra4king's Avatar
    ra4king is offline Senior Member
    Join Date
    Apr 2011
    Atlanta, Georgia, US
    Rep Power


    Do you know how to use arrays?
    I suggest you read up on them.

  3. #3
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Richmond, Virginia
    Blog Entries
    Rep Power


    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.

Similar Threads

  1. returning double array
    By Billaguana in forum New To Java
    Replies: 2
    Last Post: 01-16-2011, 03:59 AM
  2. returning array
    By aizen92 in forum New To Java
    Replies: 4
    Last Post: 01-08-2011, 03:10 PM
  3. Returning HexaDecimal Values to an Array???
    By stylishkishore in forum Advanced Java
    Replies: 5
    Last Post: 12-18-2009, 08:04 AM
  4. Returning An Array
    By elektronika in forum New To Java
    Replies: 2
    Last Post: 12-07-2009, 03:43 PM
  5. Returning array problem.
    By Chase in forum New To Java
    Replies: 4
    Last Post: 10-21-2008, 09:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts