Iterate the values of a map in Java

Description

The following code shows how to iterate the values of a map.

Example


/*from  w  ww.  jav  a 2 s . com*/
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.values().iterator(); it.hasNext();) {
      Object value = it.next();
    }
  }
}




















Home »
  Java Tutorial »
    Java Collection »




Java ArrayList
Java Collection
Java Comparable
Java Comparator
Java HashMap
Java HashSet
Java Iterator
Java LinkedHashMap
Java LinkedHashSet
Java LinkedList
Java List
Java ListIterator
Java Map
Queue
Java Set
Stack
Java TreeMap
TreeSet