数据多了用对象存,对象多了用集合存
collection
|--List:元素是有序的元素可以重复,因为该集合体系有索引,
|--Set:元素是无序的,元素不可以重复
List特有的方法:凡是可以对角标操作的都是
add(index,element)
addAll(index,Collection)
removeAll(index)
set(index,element)
get(index)
subList(from,to)
listIterator()
indexOf
在迭代时,不可以通过集合对象的方法操作集合中的元素。因为会发生ConcurrentModificationException异常
所以,在迭代时只能用迭代器的方式操作元素,可是Iterator方法是有限的,只能判断取出删除的操作,如果想要其他的操作,则需要使用子接口ListIterator,只能通过List集合的ListIterator方法获取
列表结构 链表结构
ArrayList和Vector都是数组结构,Vector线程同步被ArrayList替代了
LinkedList是链表结构,
LInkedList特有方法
addFirst
addLast
getFirst
getLast
removeFirst
removeLast
jdk1.6新出现的方法
offerFist
offerLast
peekFirst
peekLast
pollFirst
pollLast