// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;

public class LL {
    private final static int REP = 10000;
    private final static int N = 10000;
    private final static String text = "test";
    public static void main(String[] args) {
        ArrayList al = new ArrayList();
        for(int j = 0; j < N; j++) {
            al.add(text);
        }
        long t1 = System.currentTimeMillis();
        for(int i = 0; i < REP; i++) {
            for(int j = 0; j < N; j++) {
                if(!((String)al.get(i)).equals(text)) {
                    System.out.println("Oops");
                    System.exit(1);
                }
            }
        }
        long t2 = System.currentTimeMillis();
        System.out.println("AL: " + (t2 - t1));
        LinkedList ll = new LinkedList();
        for(int j = 0; j < N; j++) {
            ll.add(text);
        }
        long t3 = System.currentTimeMillis();
        for(int i = 0; i < REP; i++) {
            Iterator it = ll.iterator();
            while(it.hasNext()) {
                if(!((String)it.next()).equals(text)) {
                    System.out.println("Oops");
                    System.exit(1);
                }
            }
        }
        long t4 = System.currentTimeMillis();
        System.out.println("LL: " + (t4 - t3));
    }
}
