java.util.Map.Entry : Map « java.util « Java by API






java.util.Map.Entry

 

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class Main {
  public static void main(String[] a) {
    Map<String,String> map = new HashMap<String,String>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");
    Set set = map.entrySet();

    Iterator iter = set.iterator();

    while (iter.hasNext()) {
      Map.Entry entry = (Map.Entry) iter.next();
      System.out.println(entry.getKey() + " -- " + entry.getValue());
    }
  }
}

   
  








Related examples in the same category

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