package MapTest;
import java.util.*;
public class HashMapTest {
public static void main(String[] args) {
HashMap<String,Integer> hashMap = new HashMap();
hashMap.put("张三",12);
hashMap.put("李四",13);
hashMap.put("王五",14);
Set<Map.Entry<String, Integer>> entrySet = hashMap.entrySet();
Iterator<Map.Entry<String, Integer>> entryIterator = entrySet.iterator();
while (entryIterator.hasNext()) {
Object next = entryIterator.next();
System.out.println(next);
}
for (Map.Entry<String, Integer> stringIntegerEntry : entrySet) {
System.out.println(stringIntegerEntry);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)