Results 1 to 5 of 5

Thread: array

  1. #1
    lilac87 is offline Member
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

    Default array

    Can someone give me an example of a 2D array in java? Also what is the purpose of using it?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Have a look here: Java 2D array examples

    Please come on back if still questions after reviewing the above. Best of luck.
    Last edited by Fubarable; 07-22-2009 at 07:10 PM.

  3. #3
    lilac87 is offline Member
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

    Default

    are "2d arrays" and "parallel arrays" the same?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    are "2d arrays" and "parallel arrays" the same?
    No, they are different. Parallel arrays can be 2 dimensional, but usually I think of two or more one-dimensional arrays that hold info that is somehow linked by the indexes. For instance, if you have an array of String holding last names and another array of Strings holding first names and the i-th last name is linked to the i-th first name, that's a parallel array. These are usually not recommended, and much better would be to create a class that holds the two Strings so you can have a single array of objects of this class.

  5. #5
    lilac87 is offline Member
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

Similar Threads

  1. array or array list?
    By Drukqs in forum New To Java
    Replies: 5
    Last Post: 05-06-2009, 06:37 PM
  2. Replies: 1
    Last Post: 03-31-2009, 06:40 AM
  3. String array to byte array?!
    By Joe2003 in forum Advanced Java
    Replies: 5
    Last Post: 02-28-2009, 06:09 AM
  4. Array Reflection: Multi Array Reflection
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 08:08 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
  •