首页 > 代码库 > java循环遍历map

java循环遍历map

import java.util.HashMap;import java.util.Iterator;import java.util.Map;public class MapTest {	public static void main(String args[]) {		Map<Integer, String> map = new HashMap<Integer, String>();				for (int i = 0; i < 2000; i++) {			map.put(i, i * 10 + "");		}		// 第一种:通过Map.keySet()遍历key和value		// 这里有一个二次取值的过程,所以并不推荐		for (Integer key : map.keySet()) {			System.out.println("key = " + key + " and value = "http://www.mamicode.com/+ map.get(key));"key = " + entry.getKey() + " and value = "http://www.mamicode.com/+ entry.getValue());"key = " + entry.getKey() + " and value = "http://www.mamicode.com/+ entry.getValue());>

  

java循环遍历map