Results 1 to 3 of 3
  1. #1
    quickbix is offline Member
    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Default how to dynamically populate Hashmaps

    hi,

    I am reading a xls and want to populate my hashmap with <K,V> where K is the values which I read from xls and V is an integer variable with initial value 1 . if the K already exists then only the vlaue should be incremented and if the vlaue read from the xls is new then a new <K,V> pair should be created with K as the value from xls and V as 1 .

    below is the code I am using but encountering following problems-

    1) output is unexpected : {10006.0=24, 100020.0=8 , why is there a '=' sign ?
    2) either the control does not enter the if condition or the else

    whichever ways I am not getting the correct output.

    pls help

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: how to dynamically populate Hashmaps

    Moved from Advanced Java

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: how to dynamically populate Hashmaps

    Quote Originally Posted by quickbix View Post
    below is the code I am using
    Where?

    Quote Originally Posted by quickbix View Post
    but encountering following problems-

    1) output is unexpected : {10006.0=24, 100020.0=8 , why is there a '=' sign ?
    Why is that unexpected? On what are your expectations based?

    Quote Originally Posted by quickbix View Post
    2) either the control does not enter the if condition or the else
    Sounds like exactly the way I would expect if / else to behave.

    Quote Originally Posted by quickbix View Post
    whichever ways I am not getting the correct output.
    And so far, only you know what you consider to be correct.

    Quote Originally Posted by quickbix View Post
    pls help
    Sure, once you give us enough to be able to try to help.

    To get better help sooner, post a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates your problem. Use hardcoded data, we're not going to create and read a spreadsheet for a problem that so far appears to have its roots in your need to better understand the Map interface.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. hashmaps
    By santa in forum New To Java
    Replies: 6
    Last Post: 05-04-2011, 12:07 AM
  2. Populate an array dynamically
    By mmarkym in forum New To Java
    Replies: 11
    Last Post: 12-31-2010, 04:31 PM
  3. dynamically populate the city combo box based on the values of state combo +ajax+jsp
    By sandy1000 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-29-2010, 11:00 AM
  4. dynamically populate a dropdown box using jsp
    By sandy1000 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 12-27-2010, 03:21 PM
  5. Concerning HashMaps
    By hjensen in forum New To Java
    Replies: 7
    Last Post: 10-18-2010, 04:36 PM

Tags for this Thread

Posting Permissions

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