标签:不能 for ble 完成 扩展 iterator new strong ict
Map遍历
public void map() {
Map<Integer, String> books = new HashMap<>();
books.put(1, "first");
books.put(2, "second");
// 1.使用foreach
for (Object key : books.keySet()) {
System.out.println(key + "->" + books.get(key));
}
// 2.使用迭代器
for(Iterator<Map.Entry<Integer, String>> it = books.entrySet().iterator();it.hasNext();) {
System.out.println(Key + "->" + it.next().getKey());
}
}
标签:不能 for ble 完成 扩展 iterator new strong ict
原文地址:https://www.cnblogs.com/pycrab/p/8933991.html