public class LinkedHashMapDemo {
/**
* @param args
*/
public static void main(String[] args) {
HashMap<Integer, String> hm = new LinkedHashMap<Integer, String>();
hm.put(5, "wangwu");
hm.put(1, "zhaoliu");
hm.put(9, "zhouqi");
hm.put(4, "lisi");
// Set<Integer> keySet = hm.keySet();
for(Integer i : hm.keySet()){
String value = hm.get(i);
System.out.println(i+":"+value);
}
for(Map.Entry<Integer,String> me : hm.entrySet()){
Integer key = me.getKey();
String value = me.getValue();
System.out.println(key+"::::"+value);
}
/*Iterator<Map.Entry<Integer,String>> it = hm.entrySet().iterator();
while(it.hasNext()){
Map.Entry<Integer,String> me = it.next();
Integer key = me.getKey();
String value = me.getValue();
System.out.println(key+":"+value);
}*/
}
}
|
|