ArrayList及LinkedList

ArrayList

默认容量大小:

DEFAULT_CAPACITY=10;

遍历有:

for,增强for,迭代器Iterator,列表迭代器ListIterator,使用枚举器:Enumeration

 

LinkedList:

双向链表。

增强for循环
for (Object object:list) {
Student student=(Student)object;
System.out.println(student.toString());
}

//迭代器
Iterator<Object> it = list.iterator();
while (it.hasNext()){
Student s =(Student) it.next();
System.out.println(s.toString());
}

//列表迭代器
ListIterator lis = list.listIterator();
while (lis.hasNext()) {
Student s=(Student) lis.next();
System.out.println(s.toString());
}
System.out.println(list.contains(s1));

上一篇:阿里面试官:说一下ArrayList和LinkedList的区别?


下一篇:1.java面试 说说ArrayList和LinkedList区别