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.


>> REGISTER NOW TO START POSTING


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

Results 1 to 2 of 2

Thread: Help me to Choose Collections

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help me to Choose Collections

    Hi
    I need to store a single key multiple values,how i want a collection is

    key1,value1,value2,value3....
    key2,value1,value2....

    please suggest me a suitable collection for the above scenario and help me how to retrieve those values
    for eg
    for the first iteration my output should be

    key1
    value1,value2,value3

    for the second iteration my output should be
    key1
    value1,value2
    Please help me.. thanks in advance


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Help me to Choose Collections

    A Map that contains a List as the value. Something like:
    Map<String, List<String>> map = new HashMap<String, List<String>>();
    List<String> list = new ArrayList<String>();
    list.add("1");
    list.add("2");
    map.put("First", list);

Similar Threads

  1. Generics collections and reflection
    By juza in forum Collections and Generics
    Replies: 2
    Last Post: November 30th, 2010, 03:14 AM
  2. how to sort objects with collections???
    By kyros in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 31st, 2010, 02:21 PM
  3. How do I let the user choose how big an array is...
    By Roon Hapoon in forum Collections and Generics
    Replies: 2
    Last Post: October 5th, 2010, 12:15 AM
  4. why should i choose java over others?
    By docesam in forum Java Theory & Questions
    Replies: 9
    Last Post: August 30th, 2009, 10:49 PM
  5. Replies: 0
    Last Post: May 21st, 2009, 11:17 AM