| java.lang.Object | |||
| ↳ | java.util.AbstractCollection<E> | ||
| ↳ | java.util.AbstractList<E> | ||
| ↳ | java.util.ArrayList<E> | ||
ArrayList is an implementation of List, backed by an array. All optional operations are supported, adding, removing, and replacing. The elements can be any objects.
|
[Expand]
Inherited Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.util.AbstractList
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new instance of ArrayList with zero capacity.
| |||||||||||
Constructs a new instance of ArrayList with the specified capacity.
| |||||||||||
Constructs a new instance of ArrayList containing the elements in the
specified collection.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Inserts the specified object into this ArrayList at the specified
location.
| |||||||||||
Adds the specified object at the end of this ArrayList.
| |||||||||||
Inserts the objects in the specified Collection at the specified location
in this ArrayList.
| |||||||||||
Adds the objects in the specified Collection to this ArrayList.
| |||||||||||
Removes all elements from this ArrayList, leaving it empty.
| |||||||||||
Returns a new ArrayList with the same elements, size and capacity as this
ArrayList.
| |||||||||||
Searches this ArrayList for the specified object.
| |||||||||||
Ensures that this ArrayList can hold the specified number of elements
without growing.
| |||||||||||
Returns the element at the specified location in this ArrayList.
| |||||||||||
Searches this ArrayList for the specified object and returns the index of
the first occurrence.
| |||||||||||
Returns if this ArrayList has no elements, a size of zero.
| |||||||||||
Searches this ArrayList for the specified object and returns the index of
the last occurrence.
| |||||||||||
Removes the object at the specified location from this ArrayList.
| |||||||||||
Removes the first occurrence of the specified object from this
Collection.
| |||||||||||
Replaces the element at the specified location in this ArrayList with the
specified object.
| |||||||||||
Returns the number of elements in this ArrayList.
| |||||||||||
Returns an array containing all elements contained in this ArrayList.
| |||||||||||
Returns a new array containing all elements contained in this ArrayList.
| |||||||||||
Sets the capacity of this ArrayList to be the same as the size.
| |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Removes the objects in the specified range from the start to the end, but
not including the end index.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.util.AbstractList
| |||||||||||
From class java.util.AbstractCollection
| |||||||||||
From class java.lang.Object
| |||||||||||
From interface java.lang.Iterable
| |||||||||||
From interface java.util.Collection
| |||||||||||
From interface java.util.List
| |||||||||||
Constructs a new instance of ArrayList with zero capacity.
Constructs a new instance of ArrayList with the specified capacity.
| capacity | the initial capacity of this ArrayList |
|---|
Constructs a new instance of ArrayList containing the elements in the specified collection. The ArrayList will have an initial capacity which is 110% of the size of the collection. The order of the elements in this ArrayList is the order they are returned by the collection iterator.
| collection | the collection of elements to add |
|---|
Inserts the specified object into this ArrayList at the specified location. The object is inserted before any previous element at the specified location. If the location is equal to the size of this ArrayList, the object is added at the end.
| location | the index at which to insert |
|---|---|
| object | the object to add |
| IndexOutOfBoundsException | when location < 0 || >= size()
|
|---|
Adds the specified object at the end of this ArrayList.
| object | the object to add |
|---|
Inserts the objects in the specified Collection at the specified location in this ArrayList. The objects are added in the order they are returned from the Collection iterator.
| location | the index at which to insert |
|---|---|
| collection | the Collection of objects |
| IndexOutOfBoundsException | when
location < 0 || > size()
|
|---|
Adds the objects in the specified Collection to this ArrayList.
| collection | the Collection of objects |
|---|
Returns a new ArrayList with the same elements, size and capacity as this ArrayList.
Searches this ArrayList for the specified object.
| object | the object to search for |
|---|
object is an element of this ArrayList,
false otherwise
Ensures that this ArrayList can hold the specified number of elements without growing.
| minimumCapacity | the minimum number of elements that this ArrayList will hold before growing |
|---|
Returns the element at the specified location in this ArrayList.
| location | the index of the element to return |
|---|
| IndexOutOfBoundsException | when location < 0 || >= size()
|
|---|
Searches this ArrayList for the specified object and returns the index of the first occurrence.
| object | the object to search for |
|---|
Returns if this ArrayList has no elements, a size of zero.
Searches this ArrayList for the specified object and returns the index of the last occurrence.
| object | the object to search for |
|---|
Removes the object at the specified location from this ArrayList.
| location | the index of the object to remove |
|---|
| IndexOutOfBoundsException | when location < 0 || >= size()
|
|---|
Removes the first occurrence of the specified object from this Collection. This operation traverses over the collection, looking for the specified object. Once the object is found, the object will be removed from the collection using the iterator's remove method. This collection will throw an UnsupportedOperationException if the iterator returned does not implement remove method, and the specified object is in this collection.
| object | the object to remove |
|---|
Replaces the element at the specified location in this ArrayList with the specified object.
| location | the index at which to put the specified object |
|---|---|
| object | the object to add |
| IndexOutOfBoundsException | when location < 0 || >= size()
|
|---|
Returns the number of elements in this ArrayList.
Returns an array containing all elements contained in this ArrayList. If the specified array is large enough to hold the elements, the specified array is used, otherwise an array of the same type is created. If the specified array is used and is larger than this ArrayList, the array element following the collection elements is set to null.
| contents | the array |
|---|
| ArrayStoreException | when the type of an element in this ArrayList cannot be stored in the type of the specified array |
|---|
Returns a new array containing all elements contained in this ArrayList.
Sets the capacity of this ArrayList to be the same as the size.
Removes the objects in the specified range from the start to the end, but not including the end index.
| start | the index at which to start removing |
|---|---|
| end | the index one past the end of the range to remove |
| IndexOutOfBoundsException | when start < 0, start > end or
end > size()
|
|---|