public static void main(String[] args)
{
List<Integer> arrayList =
new ArrayList<Integer>();
for (int i = 0; i < 100; i++)
arrayList.add(i);
for (int i = 0; i < 100; i++)
System.out.println(arrayList.get(i));
}
public static void main(String[] args)
{
List<Integer> linkedList =
new LinkedList<Integer>();
for (int i = 0; i < 100; i++)
linkedList.add(i);
for (int i = 0; i < 100; i++)
System.out.println(linkedList.get(i));
}
public class ListIteratorTest
{
private final static int LIST_SIZE = 1000;
public static void main(String[] args)
{
List<Integer> arrayList =
new ArrayList<Integer>();
List<Integer> linkedList =
new LinkedList<Integer>();
for (int i = 0; i < LIST_SIZE; i++)
{
arrayList.add(i);
linkedList.add(i);
}
long startTime = System.currentTimeMillis();
for (int i = 0; i < arrayList.size(); i++)
arrayList.get(i);
System.out.println("ArrayList遍历速度:" + (System.currentTimeMillis() - startTime) + "ms");
startTime = System.currentTimeMillis();
for (int i = 0; i < linkedList.size(); i++)
linkedList.get(i);
System.out.println("LinkedList遍历速度:" + (System.currentTimeMillis() - startTime) + "ms");
}
}
| 1000 | 5000 | 10000 | 50000 | 100000 | |
| ArrayList | 0ms | 1ms | 2ms | 3ms | 3ms |
| LinkedList | 3ms | 16ms | 88ms | 2446ms | 18848ms |
public E get(int index) {
RangeCheck(index);
return (E) elementData[index];
}
int[3] ints = {1, 3, 5};
public E get(int index) {
return entry(index).element;
}
Node<E> node(int index) {
// assert isElementIndex(index);
if (index < (size >> 1)) {
Node<E> x = first;
for (int i = 0; i < index; i++)
x = x.next;
return x;
} else {
Node<E> x = last;
for (int i = size - 1; i > index; i--)
x = x.prev;
return x;
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有