遍历map

方式一:

for (Map.Entry<Integer, Integer> entry : map.entrySet()) {

			    System.out.println( entry.getKey() + " " + entry.getValue());

			}

方式二:

 for (Integer key : map.keySet()) {
                System.out.println(key + " " + map.get(key));
            }
遍历map中的值:

for (Integer value : map.values()) {

    System.out.println("Value = " + value);

}

对map按键排序,按值排序,可见

http://blog.csdn.net/warhin/article/details/7101180

你可能感兴趣的:(遍历map)