Results 1 to 6 of 6

Thread: Naming Arrays

  1. #1
    cs1h is offline Member
    Join Date
    Jan 2009
    Posts
    1
    Rep Power
    0

    Default Naming Arrays

    Hi,

    Is there a way to name an array from another variable.

    If I ask for a name and they give it, can I then use the name from that variable to create a new array named after their name?

    i.e. name=john (and use this to create array) int[] john = new int[2];

    All help is very much appreciated.

    Thanks,
    Cs1h

  2. #2
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default nope...

    Curious... I asked a very similar question a few days ago and the answer is no. The Java compiler needs to resolve variable names at compile time.

    [SOLVED] Can variable names be dynamically created?

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

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

    Default

    also answered in the OP's cross-post in the sun java forums.
    New To Java - Naming Arrays

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  5. #5
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default Damn !!!

    @OP: don't cross post. If you have a question/problem/doubt post it on one forum. If you don't get an answer, then you can post your question on another forum. Cross posting really irritates people (like me).

    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    And me too. Why don't those people wait for a moment and until someone answering to that. Actually they are in hurry, looking the answer in a second. And don't like to read anything as well.

Similar Threads

  1. Naming conventions
    By tim in forum Forum Lobby
    Replies: 10
    Last Post: 11-16-2008, 09:27 PM
  2. Naming object instances
    By oldgit in forum New To Java
    Replies: 9
    Last Post: 02-07-2008, 11:18 PM
  3. Naming a Class
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-22-2007, 11:21 AM
  4. RMI naming problem
    By Robbinz in forum New To Java
    Replies: 1
    Last Post: 12-06-2007, 11:32 PM
  5. Naming conventions
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-03-2007, 09:53 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
  •