• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HashMap in HashMap Doubts

 
Micheal John
Ranch Hand
Posts: 344
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm using HashMap to store data in key/value pair: below is what I'm doing..



I want to get for the key 100 and 01, the value is Hello
and 100 and 02, the value is World..

How to achieve this..is there any api for this..or we have to use like StringTokenzier..?
 
Joanne Neal
Rancher
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
returns a HashMap, so just iterate through that the same way as you iterated thru h3.
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean somewhat like this?

 
Micheal John
Ranch Hand
Posts: 344
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's seems to be generics.. only supported in 1.5..? i am using i.4..?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The logic will be the same though. 1.4 version:
 
Micheal John
Ranch Hand
Posts: 344
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks paul, Edwin and also neal..
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The logic will be the same though. 1.4 version:


Did you not miss the casting, Paul?

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup Teach me for just regexing out the generics syntax...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic