public class compareArrayListLinkedList{
public static void main(String[] args) {
//定义两个集合
ArrayList<String> list = new ArrayList<String>();
LinkedList<String> list1 = new LinkedList<String>();
//计算ArrayList的100万次的增删时间
long long1 = System.currentTimeMillis();
for(int i = 0; i < 1000000; i++)
list.add("i"+i);
for(int i = 1; i < 9999; i++)
list.remove("i"+i);
System.out.println(System.currentTimeMillis()-long1);
//计算LinkedList的100万次的增删时间
long long2 = System.currentTimeMillis();
for(int i = 0; i < 1000000; i++)
list1.add("i"+i);
for(int i = 1; i < 9999; i++)
list1.remove("i"+i);
System.out.println(System.currentTimeMillis()-long2);