Posted by:
Instanceofjava
Posted date:
December 08, 2014
/
Java Programs
- package com.instaceofjava;
-
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.Map;
- import java.util.Map.Entry;
-
- public class Mapiterator {
-
- public static void main(String[] args) {
-
- HashMap map=new HashMap();
-
- map.put(1, "indhu");
- map.put("d", "sindhu");
- map.put("3", "swathi");
-
- if(!map.isEmpty()){
-
- Iterator it=map.entrySet().iterator();
-
- while(it.hasNext()){
-
- Map.Entry obj=(Entry) it.next();
- System.out.println(obj.getValue());
-
- }
-
- }
-
- }
-
- }
Output: