加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090309180919/http://developer.android.com:80/reference/java/util/List.html
public interface

List

implements Collection<E>
java.util.List<E>
Known Indirect Subclasses

Class Overview

List is a collection which maintains an ordering for its elements. Every element in the list has an index.

Summary

Public Methods
abstract void add(int location, E object)
Inserts the specified object into this Vector at the specified location.
abstract boolean add(E object)
Adds the specified object at the end of this List.
abstract boolean addAll(int location, Collection<? extends E> collection)
Inserts the objects in the specified Collection at the specified location in this List.
abstract boolean addAll(Collection<? extends E> collection)
Adds the objects in the specified Collection to the end of this List.
abstract void clear()
Removes all elements from this List, leaving it empty.
abstract boolean contains(Object object)
Searches this List for the specified object.
abstract boolean containsAll(Collection<?> collection)
Searches this List for all objects in the specified Collection.
abstract boolean equals(Object object)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
abstract E get(int location)
Returns the element at the specified location in this List.
abstract int hashCode()
Returns an integer hash code for the receiver.
abstract int indexOf(Object object)
Searches this List for the specified object and returns the index of the first occurrence.
abstract boolean isEmpty()
Returns if this List has no elements, a size of zero.
abstract Iterator<E> iterator()
Returns an Iterator on the elements of this List.
abstract int lastIndexOf(Object object)
Searches this List for the specified object and returns the index of the last occurrence.
abstract ListIterator<E> listIterator()
Returns a ListIterator on the elements of this List.
abstract ListIterator<E> listIterator(int location)
Returns a ListIterator on the elements of this List.
abstract E remove(int location)
Removes the object at the specified location from this List.
abstract boolean remove(Object object)
Removes the first occurrence of the specified object from this List.
abstract boolean removeAll(Collection<?> collection)
Removes all occurrences in this List of each object in the specified Collection.
abstract boolean retainAll(Collection<?> collection)
Removes all objects from this List that are not contained in the specified Collection.
abstract E set(int location, E object)
Replaces the element at the specified location in this List with the specified object.
abstract int size()
Returns the number of elements in this List.
abstract List<E> subList(int start, int end)
Returns a List of the specified portion of this List from the start index to one less than the end index.
abstract <T> T[] toArray(T[] array)
Returns an array containing all elements contained in this List.
abstract Object[] toArray()
Returns an array containing all elements contained in this List.
[Expand]
Inherited Methods
From interface java.lang.Iterable
From interface java.util.Collection

Public Methods

public abstract void add (int location, E object)

Inserts the specified object into this Vector 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 List, the object is added at the end.

Parameters
location the index at which to insert
object the object to add
Throws
UnsupportedOperationException when adding to this List is not supported
ClassCastException when the class of the object is inappropriate for this List
IllegalArgumentException when the object cannot be added to this List
IndexOutOfBoundsException when location < 0 || >= size()

public abstract boolean add (E object)

Adds the specified object at the end of this List.

Parameters
object the object to add
Returns
  • true
Throws
UnsupportedOperationException when adding to this List is not supported
ClassCastException when the class of the object is inappropriate for this List
IllegalArgumentException when the object cannot be added to this List

public abstract boolean addAll (int location, Collection<? extends E> collection)

Inserts the objects in the specified Collection at the specified location in this List. The objects are added in the order they are returned from the Collection iterator.

Parameters
location the index at which to insert
collection the Collection of objects
Returns
  • true if this List is modified, false otherwise
Throws
UnsupportedOperationException when adding to this List is not supported
ClassCastException when the class of an object is inappropriate for this List
IllegalArgumentException when an object cannot be added to this List
IndexOutOfBoundsException when location < 0 || >= size()

public abstract boolean addAll (Collection<? extends E> collection)

Adds the objects in the specified Collection to the end of this List. The objects are added in the order they are returned from the Collection iterator.

Parameters
collection the Collection of objects
Returns
  • true if this List is modified, false otherwise
Throws
UnsupportedOperationException when adding to this List is not supported
ClassCastException when the class of an object is inappropriate for this List
IllegalArgumentException when an object cannot be added to this List

public abstract void clear ()

Removes all elements from this List, leaving it empty.

Throws
UnsupportedOperationException when removing from this List is not supported
See Also

public abstract boolean contains (Object object)

Searches this List for the specified object.

Parameters
object the object to search for
Returns
  • true if object is an element of this List, false otherwise

public abstract boolean containsAll (Collection<?> collection)

Searches this List for all objects in the specified Collection.

Parameters
collection the Collection of objects
Returns
  • true if all objects in the specified Collection are elements of this List, false otherwise

public abstract boolean equals (Object object)

Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.

Parameters
object Object the object to compare with this object.
Returns
  • boolean true if the object is the same as this object false if it is different from this object.
See Also

public abstract E get (int location)

Returns the element at the specified location in this List.

Parameters
location the index of the element to return
Returns
  • the element at the specified location
Throws
IndexOutOfBoundsException when location < 0 || >= size()

public abstract int hashCode ()

Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method.

Returns
  • the receiver's hash
See Also

public abstract int indexOf (Object object)

Searches this List for the specified object and returns the index of the first occurrence.

Parameters
object the object to search for
Returns
  • the index of the first occurrence of the object

public abstract boolean isEmpty ()

Returns if this List has no elements, a size of zero.

Returns
  • true if this List has no elements, false otherwise
See Also

public abstract Iterator<E> iterator ()

Returns an Iterator on the elements of this List. The elements are iterated in the same order that they occur in the List.

Returns
  • an Iterator on the elements of this List
See Also

public abstract int lastIndexOf (Object object)

Searches this List for the specified object and returns the index of the last occurrence.

Parameters
object the object to search for
Returns
  • the index of the last occurrence of the object

public abstract ListIterator<E> listIterator ()

Returns a ListIterator on the elements of this List. The elements are iterated in the same order that they occur in the List.

Returns
  • a ListIterator on the elements of this List
See Also

public abstract ListIterator<E> listIterator (int location)

Returns a ListIterator on the elements of this List. The elements are iterated in the same order that they occur in the List. The iteration starts at the specified location.

Parameters
location the index at which to start the iteration
Returns
  • a ListIterator on the elements of this List
Throws
IndexOutOfBoundsException when location < 0 || >= size()
See Also

public abstract E remove (int location)

Removes the object at the specified location from this List.

Parameters
location the index of the object to remove
Returns
  • the removed object
Throws
UnsupportedOperationException when removing from this List is not supported
IndexOutOfBoundsException when location < 0 || >= size()

public abstract boolean remove (Object object)

Removes the first occurrence of the specified object from this List.

Parameters
object the object to remove
Returns
  • true if this List is modified, false otherwise
Throws
UnsupportedOperationException when removing from this List is not supported

public abstract boolean removeAll (Collection<?> collection)

Removes all occurrences in this List of each object in the specified Collection.

Parameters
collection the Collection of objects to remove
Returns
  • true if this List is modified, false otherwise
Throws
UnsupportedOperationException when removing from this List is not supported

public abstract boolean retainAll (Collection<?> collection)

Removes all objects from this List that are not contained in the specified Collection.

Parameters
collection the Collection of objects to retain
Returns
  • true if this List is modified, false otherwise
Throws
UnsupportedOperationException when removing from this List is not supported

public abstract E set (int location, E object)

Replaces the element at the specified location in this List with the specified object.

Parameters
location the index at which to put the specified object
object the object to add
Returns
  • the previous element at the index
Throws
UnsupportedOperationException when replacing elements in this List is not supported
ClassCastException when the class of an object is inappropriate for this List
IllegalArgumentException when an object cannot be added to this List
IndexOutOfBoundsException when location < 0 || >= size()

public abstract int size ()

Returns the number of elements in this List.

Returns
  • the number of elements in this List

public abstract List<E> subList (int start, int end)

Returns a List of the specified portion of this List from the start index to one less than the end index. The returned List is backed by this list so changes to one are reflected by the other.

Parameters
start the index at which to start the sublist
end the index one past the end of the sublist
Returns
  • a List of a portion of this List
Throws
IndexOutOfBoundsException when start < 0, start > end or end > size()

public abstract T[] toArray (T[] array)

Returns an array containing all elements contained in this List. 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 List, the array element following the collection elements is set to null.

Parameters
array the array
Returns
  • an array of the elements from this List
Throws
ArrayStoreException when the type of an element in this List cannot be stored in the type of the specified array

public abstract Object[] toArray ()

Returns an array containing all elements contained in this List.

Returns
  • an array of the elements from this List