Results 1 to 6 of 6
  1. #1
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    357
    Rep Power
    5

    Default 2 dimensional array

    If I have a 2d double array (double[][] myArray), what will myArray.length return?

    for instance if I was using it to store a matrix, such that the array is[row][col] format, and my matrix was:

    3 4 5
    6 7 4
    6 4 4

    so what would myArray.length return?

  2. #2
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    it would be a length of 3

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

    Default

    I guess we're now the go-to substitute for a Java compiler. I find it's much easier asking these questions rather than writing a simple program, running it, and inspecting the output.

  4. #4
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    357
    Rep Power
    5

    Default

    I guess it was more of a "why" does it return that, instead of a what. so if I had a 3x4 matrix, would it return 4?

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

    Default

    Quote Originally Posted by sehudson View Post
    I guess it was more of a "why" does it return that, instead of a what. so if I had a 3x4 matrix, would it return 4?
    Come on, for God's sake, try it.

  6. #6
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Why? It think it is because a 2 dimensional array is just an array inside an array.

Similar Threads

  1. 2 dimensional array help!
    By ber1023 in forum New To Java
    Replies: 9
    Last Post: 01-02-2011, 01:29 AM
  2. multi or two dimensional array
    By maya700 in forum New To Java
    Replies: 4
    Last Post: 07-12-2010, 07:52 PM
  3. Two dimensional array
    By niu_niu in forum New To Java
    Replies: 4
    Last Post: 06-13-2010, 01:34 AM
  4. about two dimensional array
    By matin1234 in forum New To Java
    Replies: 2
    Last Post: 06-01-2010, 12:09 PM
  5. two-dimensional array
    By kHim in forum New To Java
    Replies: 4
    Last Post: 11-16-2008, 08:21 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
  •