Collection Review 2

几种常用Collection:
ArrayList
 An indexed sequence that grows and shrinks dynamically
可以随机访问,但是如果要从中间删除一个对象会影响效率,因为有些未删除的对象要相应的调整位置。非线程安全,但效率会比Vector要

高,如果在单线程下,选它而不是Vector。
 
LinkedList
 An ordered sequence that allows efficient insertions and removal at any location
只能按顺序访问,添加删除很方便。虽然提供了get(n)方法,但实际上还是顺序访问的,如果发现在LinkedList里面使用了这个方法,要

考虑这个List类型是否选的合适
 
HashSet
 An unordered collection that rejects duplicates
以hashcode为索引,适用于不知道所存对象位置而想寻找某个对象的情况。不可重复
 
TreeSet
 A sorted set
与HashSet类似,但是所存对象是排了序的
 
LinkedHashSet
 A set that remembers the order in which elements were inserted

 
PriorityQueue
 A collection that allows efficient removal of the smallest element
加入Queue的时候会给与一个优先级,从queue中取出的时候先取出优先级最低的
 
HashMap
 A data structure that stores key/value associations
存储key/value对,非线程安全,与HashTable相比效率要高些
 
treeMap
 A map in which the keys are sorted
排序的HashMap

LinkedHashMap
 A map that remembers the order in which entries were added

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值