1. #1
    Stood in the Fire Some Random Guy's Avatar
    Join Date
    Mar 2011
    Location
    Sweden
    Posts
    352

    [JAVA] Need help with the definition of a 2D array...

    Seems like I found a solution afterall, cheers anyways.

    I guess you can delete this whole thread... =)
    Last edited by Some Random Guy; 2013-01-10 at 07:02 PM.

  2. #2
    Epic!
    Join Date
    Dec 2009
    Location
    Toronto, Ontario
    Posts
    1,507
    Quote Originally Posted by Some Random Guy View Post
    Seems like I found a solution afterall, cheers anyways.

    I guess you can delete this whole thread... =)
    You should edit your post with the question/answer for people who find this through google.

    There's nothing worse spending hours searching for an answer on google when all you find are forum topics with people who respond with

    Just google it
    or

    nvm, sorry figured it out
    (This signature was removed for violation of the Avatar & Signature Guidelines)

  3. #3
    For those wanting the answer, a 2D array is essentially an array of arrays, where in each element of the outer array points to a different inner array.
    It is declared like such:
    Code:
    int[][] myArray = new int[SizeOfOuterArray][SizeOfInnerArray];
    Multidimensional arrays have a wide range of uses, but 2D arrays lend themselves exceptionally well to situations where you would organize the information as a grid. You can also add more than 2 dimensions to a multidimensional array.

    Consider the grid:
    Code:
    A B C
    D E F
    G H I
    Let's imagine this is the visual representation of a char[3][3] array. Element[0][0] is A, and element [2][2] is I, and so on.
    Last edited by Shamypriest; 2013-01-10 at 10:25 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
  •