-
无参的构造函数: ArrayList()构造一个初始容量为10的空列表。
/** * Constructs an empty list with an initial capacity of ten. */ public ArrayList() { this.elementData = DEFAULTCAPACITY_EMPTY_ELEMENTDATA; }
-
一个指定collection的构造函数: ArrayList(Collection<? extends E> c)构造一个包含指定collection的元素的列表,这些元素是按照该collection的迭代器返回它们的顺序排列的。
/** * Constructs a list containing the elements of the specified * collection, in the order they are returned by the collection's * iterator */ public ArrayList(Collection<? extends E> c)
-
一个int类型的构造函数: ArrayList(int initialCapacity)构造一个具有指定初始容量的空列表。
/** * Constructs an empty list with the specified initial capacity. */ public ArrayList(int initialCapacity)
ArrayList的三个构造函数
最新推荐文章于 2025-06-03 22:47:35 发布