Mega Code Archive

 
Categories / Java / Collections Data Structure
 

For both the keys and values of a map

import java.util.HashMap; import java.util.Iterator; import java.util.Map; public class Main {   public static void main(String[] argv) throws Exception {     Map map = new HashMap();     for (Iterator it = map.entrySet().iterator(); it.hasNext();) {       Map.Entry entry = (Map.Entry) it.next();       Object key = entry.getKey();       Object value = entry.getValue();     }   } }