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 6 of 6

Thread: MultiHashMap

  1. #1
    Member
    Join Date
    Sep 2012
    Location
    The Netherlands
    Posts
    84
    My Mood
    Inspired
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default MultiHashMap

    Is there a way that I can get back how many vales are stored with a certain key?

    Like:

    Key = 1, Values = Max, Owen, Karl, Jonas, Rose

    Number of values would be: 5.
    But how do I get my program to tell me the amount?
    Becasue mapFile1.getValues.size() doesn't work.

    Or how do I let it print every value on a new line?
    Last edited by Purple01; September 18th, 2012 at 04:30 AM.


  2. #2
    Member
    Join Date
    Mar 2011
    Posts
    114
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: MultiHashMap

    have a question reg ur query.
    Ur key say "1" will have multiple values (i.e. could be a list) as Max, Owen, Karl, Jonas, Rose.
    And u want to pring the size of values for key ="1"?

  3. #3
    Member
    Join Date
    Sep 2012
    Location
    The Netherlands
    Posts
    84
    My Mood
    Inspired
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: MultiHashMap

    Okey, so this is my whole problem:

    I have a MultiHashMap.
    Who has a key with multiple values.
    Now I am trying to save those values in an excel file.
    Every value a new cell.

    Now I now how to do the excel part.
    XSSFCell cellAA = rowA.createCell(i);

    Now i needs to be number of values a certain key has.

    But how do I let it count how many values are with a certain key?
    After that I would like to print them one by one.

    That is my problem.
    After that my program is almost finished.

  4. #4
    Member
    Join Date
    Sep 2012
    Location
    The Netherlands
    Posts
    84
    My Mood
    Inspired
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: MultiHashMap

    This is the code I have to grab the key and the entry:

    if (Match.equals(entry.getKey())) {
            				System.out.println(entry.getValue());
            			}

    But now to print every value seperate too.

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: MultiHashMap

    a key with multiple values.
    I don't understand how that works. A key should be associated with one value.
    The object that is the value can contain anything, but there is still only one value associated with a key.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Member
    Join Date
    Sep 2012
    Location
    The Netherlands
    Posts
    84
    My Mood
    Inspired
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: MultiHashMap

    I have used a Api where it was in.
    I was thinking it was always usable, so that explain why it did work in my code.

    But I found the answer on how to do this.
    Now I can work things out to save the file.

    Thanks for the replies.

Similar Threads

  1. MultiHashMap - won't give the values back.
    By Purple01 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 18th, 2012, 03:27 AM