package cn.com;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
public class PlMap {
public static void main(String[] args) {
ArrayList list = new ArrayList();
Map hash = new HashMap();
TreeMap treeMap = new TreeMap();
list.add("a");
list.add("b");
list.add("c");
hash.put(3, 3);
hash.put(4, 4);
hash.put(5, 5);
hash.put(6, 6);
hash.put(1, 1);
hash.put(2, 2);
treeMap.put(1, 1);
treeMap.put(2, 2);
treeMap.put(3, 3);
treeMap.put(4, 4);
treeMap.put(5, 5);
treeMap.put(6, 6);
//list遍历
for(Object m: list){
System.out.println(m);
}
// hashmap entrySet() 遍历
for(Object m0: hash.entrySet()){
System.out.println(((Map.Entry)m0).getKey()+"---"+((Map.Entry)m0).getValue());
// System.out.println("map"+m0+"---"+hash.get(m0));
}
//hashmap keySet() 遍历
for(Object m: hash.keySet()){
System.out.println("hashmap"+m+"---"+hash.get(m));
}
// treemap keySet()遍历
for(Object m: treeMap.keySet()){
System.out.println(m+"---"+treeMap.get(m));
}
}
}