con*_*ner 11 java collections linked-list arraylist
我何时应该使用arrayList?何时应该使用LinkedList?
什么时候应该使用TreeSet,LinkedHashSet并HashSet?
Ahm*_*mad 13
When should i use arrayList and when should I go for LinkedList?
Run Code Online (Sandbox Code Playgroud)
Arraylist维护像数组一样的索引.因此,如果想要更频繁的获取操作,那么arraylist最好去.
LinkedList维护指向元素的指针.你不能像arraylist那样的特定索引.但是链接列表中的优势在于它们不需要像arraylist那样来回移动来维持连续索引.因此,在链表中获取操作的成本很高,因为您必须通过指针来获取元素.但与arraylist相比,put操作是好的.你只需要连接到指针就可以了.
When should I use TreeSet, LinkedHashSet and HashSet?
Run Code Online (Sandbox Code Playgroud)
区别仅在于订购.treeset元素需要维护由您的成员对象定义的特定订单.
| 归档时间: |
|
| 查看次数: |
21906 次 |
| 最近记录: |