Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extracting values from HashMap

I was trying to learn and make understanding out of the working of a HashMap. So i created this hashmap to store certain values which upon displaying using an Iterator gives me outputs as

 1=2
 2=3
 3=4

and so on. This output i obtain using the Iterator.next() function. Now what my actual doubt is that since the type of this value returned in of an Iterator Object, if i need to extract only the right hand side values of the above equalities, is there any function for that? Something like a substring. Is there any way i could just get results as

 2
 3
 4

Any help will be appreciated. thanks in advance.

like image 687
Anurag Ramdasan Avatar asked Apr 16 '12 19:04

Anurag Ramdasan


1 Answers

I would use something like

Map<Integer, Integer> map = new HashMap<>();

for(int value: map.values())
   System.out.println(value);
like image 112
Peter Lawrey Avatar answered Sep 30 '22 19:09

Peter Lawrey