M*a
3 楼
map不能多线程。table能。貌似是。
f*n
4 楼
There are several differences between HashMap and Hashtable in Java:
Hashtable is synchronized, whereas HashMap is not. This makes HashMap better
for non-threaded applications, as unsynchronized Objects typically perform
better than synchronized ones.
Hashtable does not allow null keys or values. HashMap allows one null key
and any number of null values.
One of HashMap's subclasses is LinkedHashMap, so in the event that you'd
want predictable iteration order (which is insertion order by default), you
could easily swap out the HashMap for a LinkedHashMap. This wouldn't be as
easy if you were using Hashtable.
Hashtable is synchronized, whereas HashMap is not. This makes HashMap better
for non-threaded applications, as unsynchronized Objects typically perform
better than synchronized ones.
Hashtable does not allow null keys or values. HashMap allows one null key
and any number of null values.
One of HashMap's subclasses is LinkedHashMap, so in the event that you'd
want predictable iteration order (which is insertion order by default), you
could easily swap out the HashMap for a LinkedHashMap. This wouldn't be as
easy if you were using Hashtable.
g*g
5 楼
HashTable就是个 legacy class, 需要thread safe也应该用 ConcurrentHashMap.
x*1
7 楼
好虫赶紧给讲讲java 8吧。
R*o
8 楼
hashtable已经是legacy了,不怎么用了,这个区别网上搜一下就差不多了,面试也会
考。
考。
相关阅读
洗完澡, 裸着体background check到底查什么?又被据了吐槽一下leet codeOnsite后,HR要我legal name和家庭地址,要再打个电话给我Flg promotion导师换学校简历怎么写?Senior Software Developer 的面试和思考真悲剧,onsite前夜发现忘了带皮带everstring好像是中国公司?Amazon内推 各种职位均可但以robotics,ML和fulfillment techno请教一道二叉树的题G签了offer不去什么后果?UberPOOL backend 招人akamai怎么样猎头的职位薪水如何?intern vs full timeOPT 延期申请从NSC被转到Potomac service center这个offer 扣除各种税费,在弯曲年薪到手能拿多少万?两个intern对以后找工作更有用呢?