Map: keySet()


/*
Key Adobe; Value Mountain View, CA
Key IBM; Value White Plains, NY
Key Learning Tree; Value Los Angeles, CA
*/       
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class MainClass {

  public static void main(String[] argv) {
    Map map = new HashMap();

    map.put("Adobe", "Mountain View, CA");
    map.put("IBM", "White Plains, NY");
    map.put("Learning Tree", "Los Angeles, CA");

    Iterator k = map.keySet().iterator();
    while (k.hasNext()) {
      String key = (String) k.next();
      System.out.println("Key " + key + "; Value " + (String) map.get(key));
    }
  }
}
Home 
  Java Book 
    Collection  

Map:
  1. Map
  2. implements Map
  3. java.util.Map.Entry
  4. Map: clear()
  5. Map: containsKey(Object key)
  6. Map: containsValue(Object value)
  7. Map: equals(Object o)
  8. Map: get(Object key)
  9. Map.Entry: getKey()
  10. Map.Entry: getValue()
  11. Map: keySet()
  12. Map: put(T key, T value)
  13. Map: putAll(Map<?, ?> m)
  14. Map: remove(Object key)
  15. Map: size()
  16. Map: values()