• Post Reply Bookmark Topic Watch Topic
  • New Topic

Retrieving values from a HashMap  RSS feed

 
neha priya
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone,

i have declared a HashMap


now i want to retrieve values(the arraylist of eventrows added) from the HashMap and print them...how do i do it?

please reply
thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you know the key (which is an Integer), you can retrieve values by calling the get method of the map.
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you just need to get the values, which is list of EventRow, just call Map.values().
 
satish varma
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to retrive there are many ways

Set keySet() ---->to get all keys
Collection values() ---->to get all values
Set entrySet() ---->to get objects one by one

to get objects from entrySet we should use "Iterator" cursor(it is a interface to retriev objects one by one from Collection object)
each key value pair treated as one entry. Entry is the inner interface of Map, the structure is below


digg more things from other resources and see some examples
see below example then i hope it gives clear explaination

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!