

The length of the returned array is equal to the number of elements Returned by this collection's iterator, in the same order, stored inĬonsecutive elements of the array, starting with index 0. This implementation returns an array containing all the elements This method acts as bridge between array-based and collection-based
JAVA COLLECTIONS CONTAINS FREE
The caller is thus free to modify the returned array. (In other words, this method mustĪllocate a new array even if this collection is backed by an array). The returned array will be "safe" in that no references to it are If this collection makes any guarantees as to what order its elementsĪre returned by its iterator, this method must return the elements in Public Object toArray() Returns an array containing all of the elements in this collection. NullPointerException - if the specified element is null and thisĬollection does not permit null elements (optional) Is incompatible with this collection (optional) Throws: ClassCastException - if the type of the specified element Returns: true if this collection contains the specified Specified by: contains in interface Collection Parameters: o - element whose presence in this collection is to be tested This implementation iterates over the elements in the collection,Ĭhecking each element in turn for equality with the specified element. More formally, returns true if and only if this collectionĬontains at least one element e such that Public boolean contains( Object o) Returns true if this collection contains the specified element. Specified by: isEmpty in interface Collection Returns: true if this collection contains no elements Public boolean isEmpty() Returns true if this collection contains no elements. Specified by: size in interface Collection Returns: the number of elements in this collection If this collectionĬontains more than Integer.MAX_VALUE elements, returns Public abstract int size() Description copied from interface: Collection Returns the number of elements in this collection. Specified by: iterator in interface Iterable Specified by: iterator in interface Collection Returns: an iterator over the elements contained in this collection Public abstract Iterator iterator() Returns an iterator over the elements contained in this collection. (For invocation by subclass constructors, typically Protected AbstractCollection() Sole constructor. Methods inherited from interface java.util. ObjectĬlone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait Returns a string representation of this collection. The runtime type of the returned array is that of the specified array. Returns an array containing all of the elements in this collection Returns an array containing all of the elements in this collection. Returns the number of elements in this collection. Retains only the elements in this collection that are contained in the Specified collection (optional operation). Removes all of this collection's elements that are also contained in the Removes a single instance of the specified element from thisĬollection, if it is present (optional operation). Returns an iterator over the elements contained in this collection. Returns true if this collection contains no elements. Returns true if this collection contains all of the elements


Returns true if this collection contains the specified element. Removes all of the elements from this collection (optional operation). The collection being implemented admits a more efficient implementation.Įnsures that this collection contains the specified element (optionalĪdds all of the elements in the specified collection to this collection Each of these methods may be overridden if The documentation for each non-abstract method in this class describes its

The programmer should generally provide a void (no argument) andĬollection constructor, as per the recommendation in the Iterator method must additionally implement its remove UnsupportedOperationException), and the iterator returned by the Override this class's add method (which otherwise throws an To implement a modifiable collection, the programmer must additionally To implement an unmodifiable collection, the programmer needs only toĮxtend this class and provide implementations for the iterator and Interface, to minimize the effort required to implement this interface. This class provides a skeletal implementation of the Collection Public abstract class AbstractCollection extends Object implements Collection SUMMARY: NESTED | FIELD | CONSTR | METHODĬlass AbstractCollection All Implemented Interfaces: Iterable, Collection Direct Known Subclasses: AbstractList, AbstractQueue, AbstractSet, ArrayDeque
