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

Collection

implements Iterable<T>
java.util.Collection<E>
Known Indirect Subclasses

Class Overview

Collection is the root of the collection hierarchy.

Summary

Public Methods
abstract boolean add(E object)
Attempts to add object to the contents of this Collection.
abstract boolean addAll(Collection<? extends E> collection)
Attempts to add all of the objects contained in collection to the contents of this collection.
abstract void clear()
Removes all elements from this Collection, leaving it empty.
abstract boolean contains(Object object)
Searches this Collection for the specified object.
abstract boolean containsAll(Collection<?> collection)
Searches this Collection 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 int hashCode()
Returns an integer hash code for the receiver.
abstract boolean isEmpty()
Returns if this Collection has no elements, a size of zero.
abstract Iterator<E> iterator()
Returns an instance of Iterator that may be used to access the objects contained by this collection.
abstract boolean remove(Object object)
Removes the first occurrence of the specified object from this Collection.
abstract boolean removeAll(Collection<?> collection)
Removes all occurrences in this Collection of each object in the specified Collection.
abstract boolean retainAll(Collection<?> collection)
Removes all objects from this Collection that are not also found in the contents of collection.
abstract int size()
Returns a count of how many objects are contained by this collection.
abstract <T> T[] toArray(T[] array)
Returns an array containing all elements contained in this Collection.
abstract Object[] toArray()
Returns a new array containing all elements contained in this Collection.
[Expand]
Inherited Methods
From interface java.lang.Iterable

Public Methods

public abstract boolean add (E object)

Attempts to add object to the contents of this Collection.

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

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

Attempts to add all of the objects contained in collection to the contents of this collection.

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

public abstract void clear ()

Removes all elements from this Collection, leaving it empty.

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

public abstract boolean contains (Object object)

Searches this Collection for the specified object.

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

public abstract boolean containsAll (Collection<?> collection)

Searches this Collection 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 Collection, 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 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 boolean isEmpty ()

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

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

public abstract Iterator<E> iterator ()

Returns an instance of Iterator that may be used to access the objects contained by this collection.

Returns
  • an iterator for accessing the collection contents

public abstract boolean remove (Object object)

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

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

public abstract boolean removeAll (Collection<?> collection)

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

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

public abstract boolean retainAll (Collection<?> collection)

Removes all objects from this Collection that are not also found in the contents of collection.

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

public abstract int size ()

Returns a count of how many objects are contained by this collection.

Returns
  • how many objects are contained by this collection

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

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

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

public abstract Object[] toArray ()

Returns a new array containing all elements contained in this Collection.

Returns
  • an array of the elements from this Collection