Hashtable:
1. key和value都不许有null值
2. 使用enumeration遍历
3. 同步的,每次只有一个线程能够访问
4. 在java中Hashtable是H大写,t小写,而HashMap是H大写,M大写
HashMap:
1. key和value可以有null值
2. 使用iterator遍历
3. 未同步的,多线程场合要手动同步HashMap
HashSet
1. 底层调用HashMap
2. 不允许有重复值
常用Java操作:
1 Hashtable<Integer, Integer> ht=new Hashtable<Integer, Integer>(); 2 ht.put(key, value); 3 ht.containsKey(key); 4 ht.containsValue(value); 5 ht.remove(key); 6 ht.remove(key, value); 7 8 HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>(); 9 hm.put(key, value); 10 hm.containsKey(key); 11 hm.containsValue(value); 12 hm.remove(key); 13 hm.remove(key, value); 14 15 HashSet<Integer> hs = new HashSet<Integer>(); 16 hs.add(e); 17 hs.contains(o); 18 hs.remove(o);
Reference:
http://www.cnblogs.com/springfor/p/3859628.html
http://blog.sina.com.cn/s/blog_4586764e0100ivup.html
http://www.blogjava.net/fisher/archive/2006/12/13/87398.html
http://blog.csdn.net/wl_ldy/article/details/5941770
http://www.pakzilla.com/2009/08/24/hashmap-vs-hashtable-vs-hashset/