This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in iterating HashMap

 
Keerthi Kumar
Ranch Hand
Posts: 105
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I am facing an issue while iterating Hash Map. Through a query I am fetching list of users and list of emails of those users and i am adding those to a hash map as shown below:



But the valueMap object contains the required data from the database.
Request to please help me to resolve this issue
 
Martin Vajsar
Sheriff
Pie
Posts: 3747
62
Chrome Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using an ArrayList as both a key and a value? The Map can hold multiple key-value pair on its own, you don't need to use lists to be able to put more keys/values into it. (Using a list as a key is very weird. And even if it had a merit in your case I don't see, it would still be dangerous, as the list is mutable; keys whose value can change cannot be used with a Map.)

The exception you're encountering is most likely caused because the utilDao.getUserEmailIds method is returning a null.

I'd suggest to read the Collections tutorial.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47288
52
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin Vajsar wrote: . . . keys whose value can change cannot be used with a Map. . . .
Oh, yes they can!

As long as you don’t mind all your references vanishing mysteriously whenever its hash code changes
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic