JAVA面试题整理 || ArrayList源码分析
该文章收录于:JAVA面试题整理 其他相关链接:ArrayList源码分析 ArrayList创建和add等各种api使用原理 ArrayList允许空值和重复元素,当往 ArrayList 中添加的元素数量大于其底层数组容量时,其会通过扩容机制重新生成一个更大的数组。 ArrayList是非线程安全类,并发环境下,多个线程同时操作 ArrayList,会引发不可预知的异常或错误。 ArrayList创建源码 带有初始容量的构造方法 // Shared empty array instance used for empty instances. private static final Object[] EMPTY_ELEMENTDATA = {}; /** * Constructs an empty list with the specified initial capacity. * @param initialCapacity the initial capacity of the list * @throws IllegalArgumentException if the sp...
