Map是按照key,value存值的,ArrayList是数组的形式,它是实现Collection接口的.key,value存值是实现Map接口的.
TreeMap是按照key来排序的.
例如:
public class HashMapTest {
public static void printPL(Map hm) {
Set s = hm.keySet();
Iterator i = s.iterator();
while(i.hasNext()) {
Object o = i.next();
System.out.println(o +" -- "+hm.get(o));
}
}
public static void main(String[] args) {
TreeMap hm = new TreeMap();
hm.put("ha3",new Integer(1003));
hm.put("ha0",new Integer(1000));
hm.put("ha2",new Integer(1002));
hm.put("ha1",new Integer(1001));
printPL(hm);
}
}
更多见 http://hi.baidu.com/sunkuan56/blog/item/8b7bab369cac5dd1a3cc2be7.html