Java Map iterate via key set

Description

Java Map iterate via key set

import java.util.HashMap;
import java.util.Map;

public class Main {
  public static void main(String args[]) {
    Map<Integer, Integer> map = new HashMap<Integer, Integer>();

    map.put(1, 100);//from   www.  j  a  v  a  2 s  .  co  m
    map.put(2, 200);
    map.put(3, 300);

    for (Integer key : map.keySet()) {
      System.out.println(map.get(key));
    }
  }
}



PreviousNext

Related