/**
* 遍历hashmap的键值,通过 entrySet()方法
* @author gulijiang
*
*/
public class HashMapTest2 {
public static void main(String[] args) {
HashMap hashMap = new HashMap();
hashMap.put("a", "aa");
hashMap.put("b","bb");
hashMap.put("c","cc");
Set set = hashMap.entrySet();
for (Iterator iterator = set.iterator();iterator.hasNext();) {
Map.Entry map = (Map.Entry)iterator.next();
System.out.println(map.getKey());
System.out.println(map.getValue());
}
}
}
遍历hashmap的键值二 ,通过 entrySet()方法
最新推荐文章于 2022-09-06 15:45:02 发布