// 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.lang.reflect.Field;
import java.util.ArrayList;

// Warning: extremely implementation specific (tested with Oracle Java 1.8)
public class ArrayListStudy {
    public static void main(String[] args) throws Exception {
        Field f = ArrayList.class.getDeclaredField("elementData");
        f.setAccessible(true);
        ArrayList<String> al = new ArrayList<>(1);
        for(int i = 0; i < 64; i++) {
            al.add("ABC");
            Object[] ed = (Object[])f.get(al);
            System.out.printf("length = %d, capacity = %d, id = %s\n", i + 1, ed.length, ed.toString());
        }
    }
}
