标签:number result span ber print set 方法 hash person
//1.通过Entry来遍历HashMap
//Iterator<Entry<Integer,Person>> result = tmpHash.entrySet().iterator(); //1.通过Entry来遍历HashMap for(Entry<Integer,Person> result:tmpHash.entrySet()) { System.out.println("key="+result.getKey()+"value="+result.getValue()); }
//2.通过KeySet来获取
for(Integer key:tmpHash.keySet()) { System.out.println("key="+key+"value="+tmpHash.get(key)); }
//3.通过entrySet的iterator来获取
Iterator<Entry<Integer, Person>> it = tmpHash.entrySet().iterator(); while (it.hasNext()) { Entry<Integer, Person> entry = it.next(); System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue()); }
标签:number result span ber print set 方法 hash person
原文地址:https://www.cnblogs.com/aspirant/p/8901917.html