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

上一篇:基于一个简单开源项目litemall的长期学习和最佳实践


下一篇:计算机的组成