ArrayList tutorial with example program
By candid | Posted :
Dec 9, 2015
| Updated :
Dec 9, 2015
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, RandomAccess
Direct Known Subclasses:
AttributeList, RoleList, RoleUnresolvedList
public class ArrayListextends AbstractListimplements List, RandomAccess, Cloneable, Serializable{ //}
Since:
1.2
Field Summary
Fields inherited from class java.util.AbstractList
modCount
Constructor Summary
ArrayList()
Constructs an empty list with an initial capacity of ten.
ArrayList(Collection c)
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
ArrayList(int initialCapacity)
Constructs an empty list with the specified initial capacity.
Method Summary
Appends the specified element to the end of this list.
Inserts the specified element at the specified position in this list.
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator.
Inserts all of the elements in the specified collection into this list, starting at the specified position.
Removes all of the elements from this list.
Returns a shallow copy of this ArrayList instance.
Returns true if this list contains the specified element.
Increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
void forEach(Consumer action)
Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.
Returns the element at the specified position in this list.
Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
Returns true if this list contains no elements.
Returns an iterator over the elements in this list in proper sequence.
Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
Returns a list iterator over the elements in this list (in proper sequence).
Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.
Removes the element at the specified position in this list.
Removes the first occurrence of the specified element from this list, if it is present.
Removes from this list all of its elements that are contained in the specified collection.
boolean removeIf(Predicate filter)
Removes all of the elements of this collection that satisfy the given predicate.
protected void removeRange(int fromIndex, int toIndex)
Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive.
Replaces each element of this list with the result of applying the operator to that element.
Retains only the elements in this list that are contained in the specified collection.
Replaces the element at the specified position in this list with the specified element.
Returns the number of elements in this list.
Sorts this list according to the order induced by the specified Comparator.
Spliterator spliterator()
Creates a late-binding and fail-fast Spliterator over the elements in this list.
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
Returns an array containing all of the elements in this list in proper sequence (from first to last element).
Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that
of the specified array.
Trims the capacity of this ArrayList instance to be the list's current size.
Methods inherited from class java.util.AbstractList
equals, hashCode
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.List
containsAll, equals, hashCode
Methods inherited from interface java.util.Collection
parallelStream, stream
Related Post
Facebook
twitter
google+
pinterest
Comments