1. package com.instaceofjava; 
  2.  
  3. import java.util.HashMap;
  4. import java.util.Iterator;
  5. import java.util.Map;
  6. import java.util.Map.Entry;
  7.  
  8. public class Mapiterator {
  9.  
  10. public static void main(String[] args) {
  11.  
  12. HashMap map=new HashMap();
  13.  
  14. map.put(1, "indhu");
  15. map.put("d", "sindhu");
  16. map.put("3", "swathi");
  17.  
  18. if(!map.isEmpty()){
  19.  
  20. Iterator it=map.entrySet().iterator();
  21.  
  22. while(it.hasNext()){
  23.  
  24. Map.Entry obj=(Entry) it.next();
  25. System.out.println(obj.getValue());
  26.  
  27. }
  28.  
  29. }
  30.  
  31. }
  32.  
  33. }


Output:

  1. swathi 
  2. indhu
  3. sindhu

Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu