Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: giving arraylist name

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Thanked 0 Times in 0 Posts

    Default giving arraylist name

    Is there a way to give the name of the arraylist depending upon the input ?

    for example

    ArrayList arrname=new Arraylist();

    The above is the default one .

    instead of 'arrname' , can i give the name during execution of the program

    for example

    String name;
    Scanner s=new Scanner(System.in);
    System.out.println("Enter the arraylist name");
    ArrayList ______ =new Arraylist();

    what should be filled in so that i can get arrayname of my choice ??

    can a arraylist name be assigned like this ??

    this is my assignment

    i tried searching but cant find any solution .

    please help


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,659 Times in 2,609 Posts

    Default Re: giving arraylist name

    Is there a way to give the name of the arraylist
    The names of variables are set when you type in the code.
    If you want to associate String values("names") with data use a Map where the key is the "name" and the value is the data associated with that name.

Similar Threads

  1. Simple interface example giving erors
    By user2205 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 7th, 2011, 04:11 PM
  2. Class hierarchy... giving me a headache, so I could use some help
    By Kerr in forum Object Oriented Programming
    Replies: 6
    Last Post: May 30th, 2011, 05:03 PM
  3. xml parsing getting all subtags without giving it's name
    By HungryCoder in forum Java SE APIs
    Replies: 1
    Last Post: May 27th, 2011, 03:27 AM
  4. [SOLVED] Giving Thread.sleep( ); a decimal value
    By Knox in forum Threads
    Replies: 2
    Last Post: April 9th, 2011, 08:55 PM
  5. JavaCompilerobject giving an error WITHOUT ide
    By divs1210 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 2nd, 2011, 08:49 PM