Loading
empmapNew = new HashMap(); empmapNewput("68688","Jones"); empmapNew.put("777777","Smith"); Set s = empmapNew.entrySet(); for(Iterator i = s.iterator();i.hasNext();){ Map.Entry me = (Map.Entry)i.next(); System.out.println(me.getKey() + " : " + me.getValue()); }"> Map Entry empmapNew = new HashMap(); empmapNewput("68688","Jones"); empmapNew.put("777777","Smith"); Set s = empmapNew.entrySet(); for(Iterator i = s.iterator();i.hasNext();){ Map.Entry me = (Map.Entry)i.next(); System.out.println(me.getKey() + " : " + me.getValue()); }">

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  How to read both "Key" and "Value" from the Map ?


Ans)

You could use "Map.Entry", which is key-value pair of the Map.

Below is the e.g.

  Map<String,String> empmapNew = new HashMap<String,String>();
  empmapNewput("68688","Jones");
  empmapNew.put("777777","Smith");
 
  Set s = empmapNew.entrySet();
  for(Iterator i = s.iterator();i.hasNext();){
   Map.Entry me = (Map.Entry)i.next();
   System.out.println(me.getKey() + " : " + me.getValue());

  }



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

Map Entry


Map Entry

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free