数据结构--ArrayList源码摘要
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> ArrayList源码 public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, java.io.Serializable { ...... /** * The array buffer into which the elements of the ArrayList are stored. * The capacity of the ArrayList is the length of this array buffer. */ private transient E[] elementData; /** * The size of the ArrayList (the number of elements it contains). * * @serial */ private int size; ...... } ArrayList 的底层最重要的两个属性:Object 数组和 size 属性。 ArrayList 的底层数组的调整 add方法--ArrayList源码摘要: public boolean add(E o) { ensureCapacity(size + 1)