Android
java.util
public interface

java.util.List<E>

java.util.List<E> Collection<E>

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

Known Indirect Subclasses

Summary

Public Methods

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

Details

Public Methods

public 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 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 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 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 void clear()

Removes all elements from this List, leaving it empty.

Throws

UnsupportedOperationException when removing from this List is not supported

See Also

public 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 int size()

Returns the number of elements in this List.

Returns

  • the number of elements in this List

public 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 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 Object[] toArray()

Returns an array containing all elements contained in this List.

Returns

  • an array of the elements from this List
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56