HashMap循环遍历方式

1. map.EntrySet

for(Map.Entry<String,List<String>> entry:map.entrySet()){
            entry.getKey();
            entry.getValue();
        }

2.迭代器

	Iterator<Map.Entry<String, String>> iterator = map.entrySet().iterator();
	while (iterator.hasNext()) {
		Map.Entry<String, String> entry = iterator.next();
		entry.getKey();
		entry.getValue();
	}

3.map.keySet()

	Map<String, String> map = new HashMap<String, String>();
	for (String key : map.keySet()) {
		map.get(key);
	}

4.map.entrySet

	Set<Entry<String, String>> entrySet = map.entrySet();
	for (Entry<String, String> entry : entrySet) {
	entry.getKey();
	entry.getValue();
}

你可能感兴趣的:(JAVA)