TreeMap: The map is sorted according to the natural ordering of its keys, or by a Comparator provided at map creation time, depending on which constructor is used. HashSet: It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time.Vector: 与add或insert的先后有关。LinkedList: 与add(E)或add(index,E)的先后有关。ArrayList: This class is roughly equivalent to Vector, except that it is unsynchronized.可见同样不保证顺序。所以是TreeMap 是的,初始值长度为10的一个数组
The map is sorted according to the natural ordering of its keys, or by a Comparator provided at map creation time, depending on which constructor is used. HashSet:
It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time.Vector:
与add或insert的先后有关。LinkedList:
与add(E)或add(index,E)的先后有关。ArrayList:
This class is roughly equivalent to Vector, except that it is unsynchronized.可见同样不保证顺序。所以是TreeMap
是的,初始值长度为10的一个数组
ArrayList
仔细想想。
LinkedList保持有序,需要进行全排
D) LinkedList
合适点
TreeMap用来排序不错,但跟插入数据的顺序无关Vector相对ArrayList来说,要做synchronize,除非在线程中涉及到线程安全问题,否则不考虑对于LinkedList和ArrayList的实现来说
LinkedList是用链表来实现的,ArrayList是用数组来实现的链表在实现添加/删除操作时,只需要从head遍历到指定位置,然后修改next对象的引用就行,不会有额外的负担。
数组取某一位置的对象更容易,但如果要添加/删除,就要创建新的数组对象,再用arraycopy。所以,还是LinkedList更好一些
现在看看,真汗了...经常移插的序列中要保持有序,当然是LinkedList了。
不好意思,当时没仔细看问题。