码迷,mamicode.com
首页 > 编程语言 > 详细

HashTable HashMap HashSet区别(java)

时间:2014-07-22 22:47:32      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   java   color   使用   

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         HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();
 8         hm.put(key, value);
 9         hm.containsKey(key);
10         hm.containsValue(value);
11         hm.remove(key);
12         hm.remove(key, value);

13         HashSet<Integer> hs = new HashSet<Integer>();
14         hs.add(e);
15         hs.contains(o);
16         hs.remove(o);

 bubuko.com,布布扣

Reference:

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/

HashTable HashMap HashSet区别(java),布布扣,bubuko.com

HashTable HashMap HashSet区别(java)

标签:style   blog   http   java   color   使用   

原文地址:http://www.cnblogs.com/springfor/p/3859628.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!