java.util
Class Arrays.ArrayList
java.lang.Object
java.util.AbstractCollection
java.util.AbstractList
java.util.Arrays.ArrayList
- All Implemented Interfaces:
- Collection, List, RandomAccess, Serializable
- Enclosing class:
- Arrays
- private static class Arrays.ArrayList
- extends AbstractList
- implements RandomAccess, Serializable
- See Also:
- Serialized Form
Method Summary |
boolean |
contains(Object o)
Returns true if this list contains the specified element.
|
Object |
get(int index)
Returns the element at the specified position in this list. |
int |
indexOf(Object o)
Returns the index in this list of the first occurence of the specified
element, or -1 if the list does not contain this element. |
Object |
set(int index,
Object element)
Replaces the element at the specified position in this list with the
specified element (optional operation). |
int |
size()
Returns the number of elements in this list. |
Object[] |
toArray()
Returns an array containing all of the elements in this list in proper
sequence. |
Methods inherited from class java.util.AbstractList |
add, add, addAll, clear, equals, hashCode, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, subList |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
a
private Object[] a
Arrays.ArrayList
Arrays.ArrayList(Object[] array)
size
public int size()
- Description copied from interface:
List
- Returns the number of elements in this list. If this list contains
more than Integer.MAX_VALUE elements, returns
Integer.MAX_VALUE.
- Specified by:
size
in interface List
- Specified by:
size
in class AbstractCollection
- Returns:
- the number of elements in this collection.
toArray
public Object[] toArray()
- Description copied from interface:
List
- Returns an array containing all of the elements in this list in proper
sequence. Obeys the general contract of the
Collection.toArray method.
- Specified by:
toArray
in interface List
- Overrides:
toArray
in class AbstractCollection
- Returns:
- an array containing all of the elements in this collection.
get
public Object get(int index)
- Description copied from class:
AbstractList
- Returns the element at the specified position in this list.
- Specified by:
get
in interface List
- Specified by:
get
in class AbstractList
- Parameters:
index
- index of element to return.
- Returns:
- the element at the specified position in this list.
set
public Object set(int index,
Object element)
- Description copied from class:
AbstractList
- Replaces the element at the specified position in this list with the
specified element (optional operation).
This implementation always throws an
UnsupportedOperationException.
- Specified by:
set
in interface List
- Overrides:
set
in class AbstractList
- Parameters:
index
- index of element to replace.element
- element to be stored at the specified position.
- Returns:
- the element previously at the specified position.
indexOf
public int indexOf(Object o)
- Description copied from class:
AbstractList
- Returns the index in this list of the first occurence of the specified
element, or -1 if the list does not contain this element. More
formally, returns the lowest index i such that (o==null ?
get(i)==null : o.equals(get(i))), or -1 if there is no such
index.
This implementation first gets a list iterator (with
listIterator()). Then, it iterates over the list until the
specified element is found or the end of the list is reached.
- Specified by:
indexOf
in interface List
- Overrides:
indexOf
in class AbstractList
- Parameters:
o
- element to search for.
- Returns:
- the index in this List of the first occurence of the specified
element, or -1 if the List does not contain this element.
contains
public boolean contains(Object o)
- Description copied from interface:
List
- Returns true if this list contains the specified element.
More formally, returns true if and only if this list contains
at least one element e such that
(o==null ? e==null : o.equals(e)).
- Specified by:
contains
in interface List
- Overrides:
contains
in class AbstractCollection
- Parameters:
o
- object to be checked for containment in this collection.
- Returns:
- true if this collection contains the specified element.