Results 1 to 8 of 8
  1. #1
    cups is offline Member
    Join Date
    Dec 2011
    Posts
    14
    Rep Power
    0

    Default Can an array have a variable name?

    Hey there,

    the question is in the title already; I'm wondering if it's possible to have an variable array name,
    like array_i, which then would change in a for-loop; so I would have a different NAME of the array,
    when i changes, not a different index.


    cups xx

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: Can an array have a variable name?

    Why don't you just use an array of arrays?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    cups is offline Member
    Join Date
    Dec 2011
    Posts
    14
    Rep Power
    0

    Default Re: Can an array have a variable name?

    I know that would work, that's how I'm doing it right now,
    but I would like to know if it is possible? B/c it would be easier this way!

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: Can an array have a variable name?

    Quote Originally Posted by cups View Post
    I know that would work, that's how I'm doing it right now,
    but I would like to know if it is possible? B/c it would be easier this way!
    How would it be any easier?

    I suppose you could also use a Map of arrays, but what you're describing sounds exactly like an array of arrays.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: Can an array have a variable name?

    The simple answer is "no".

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

    Default Re: Can an array have a variable name?

    Quote Originally Posted by cups View Post
    B/c it would be easier this way!
    I agree with the others... how would this be easier?

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: Can an array have a variable name?

    Because the OP has done scripting languages before and it's something they're comfortable with?

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,447
    Blog Entries
    7
    Rep Power
    20

    Default Re: Can an array have a variable name?

    Some people are still so mentally tied to the Fortran way of thinking ... arrays here, arrays there, arrays everywhere ;-)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Need help adding data from an array with a variable.
    By javaguy345 in forum New To Java
    Replies: 10
    Last Post: 05-22-2011, 05:22 AM
  2. Using variable as array index
    By SalParadise in forum New To Java
    Replies: 9
    Last Post: 11-16-2010, 09:56 PM
  3. Replies: 23
    Last Post: 09-07-2010, 08:12 PM
  4. (jframe) get a variable out of array list
    By joelharkes in forum New To Java
    Replies: 9
    Last Post: 07-08-2010, 10:38 PM
  5. Array of objects, as an Instance variable
    By blaklite in forum New To Java
    Replies: 2
    Last Post: 03-25-2009, 12:56 AM

Posting Permissions

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