@SuppressWarnings("unchecked")
public static void listHashMap() {
Map hashmap = new java.util.HashMap();
for (int i = 0; i < 10; i++ ) {
hashmap.put(""+i, "thanks"+i);
}
java.util.Iterator it = hashmap.entrySet().iterator();
while (it.hasNext()) {
java.util.Map.Entry entry = (java.util.Map.Entry) it.next();
System.out.println(entry.getValue());
}
}
@SuppressWarnings("unchecked")
public static void newlistHashMap() {
Map hashmap = new java.util.HashMap();
for (int i = 0; i < 10; i++ ) {
hashmap.put(""+i, "thanks"+i);
}
Set set = hashmap.entrySet();
for (Object obj : set) {
Map.Entry e =(Map.Entry)obj;
System.out.println(e.getKey()+":"+e.getValue());
}
}
------君临天下,舍我其谁------