ArrayList 和LinkedList
package test1; import java.util.ArrayList; import java.util.LinkedList; /** * Created by Administrator on 2017/6/3 0003. */ public class ListPK { public static void main(String[] args) { ArrayList list = new ArrayList(); Object object1 = new Object(); long start = System.currentTimeMillis(); for(int i=0;i<5000000;i++) { list.add(object1); } long end = System.currentTimeMillis(); System.out.println(end-start); LinkedList list1 = new LinkedList(); Object object2 = new Object(); start = System.currentTimeMillis(); for(int i=0;i<5000000;i++) { list1.add(object1); } end = System.currentTimeMillis(); System.out.println(end-start); start = System.currentTimeMillis(); for(int i=0;i<100000;i++) { list.add(object1); } end = System.currentTimeMillis(); System.out.println(end-start); start = System.currentTimeMillis(); for(int i=0;i<100000;i++) { list1.add(object2); } end = System.currentTimeMillis(); System.out.println(end-start); start = System.currentTimeMillis(); list.add(1,1); end = System.currentTimeMillis(); System.out.println(end-start); start = System.currentTimeMillis(); list1.add(1,1); end = System.currentTimeMillis(); System.out.println(end-start); } }