• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Retrieving values from a HashMap

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you just need to get the values, which is list of EventRow, just call Map.values().
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
reply
    Bookmark Topic Watch Topic
  • New Topic