THE Java™ Programming Language, Fourth Edition
NoSuchElementException if the collection is empty. Methods or constructors that take parameters of reference type usually throw ...
through a different iterator on the same collection) is unsafe. The ListIterator interface extends Iterator, adding methods you ...
Any utility method that returns a collection will invariably be a generic method. We introduce the type variable T to represent ...
21.4. The Collection Interface As you have seen, most collection types are subtypes of the Collection interface. The only except ...
Makes sure that this collection contains the object elem, returning true if this required changing the collection. If this colle ...
public voidclear() Removes all elements from this collection. (Optional) This Collection interface is purposely very general. Ea ...
public SortedSet<E>headSet(E max) Returns a view of the set that contains all the elements of this set whose values are le ...
Creates a new HashSet with initialCapacity hash buckets and the given loadFactor, which must be a positive number. When the rati ...
publictreeSet(SortedSet<E> set) Creates a new treeSet whose initial contents will be the same as those in set and that is ...
to a sublist and can cause undefined results (so don't do it). Sublists allow you to do anything to part of a list that you coul ...
ArrayList also provides some methods to manage capacity: public voidtrimToSize() Sets the capacity to be exactly the current siz ...
Adds elem into this list as the first element. public voidaddLast(E elem) Adds elem into this list as the last element. A Linked ...
process(list.get(i)); will typically be faster than using Iterator it = list.iterator(); while (it.hasNext()) process(it.next()) ...
Queues in general should not accept null elements because null is used as a sentinel value for poll and peek to indicate an empt ...
publicPriorityQueue(SortedSet<? extends E> coll) Creates a new PriorityQueue whose initial contents are the contents of co ...
public Vget(Object key) Returns the object to which key is mapped, or null if it is not mapped. Also returns null if key has bee ...
mappings in the map. As you will see soon, Map.Entry is a nested interface with methods to manipulate the entry. The collections ...
public SortedMap<K,V>tailMap(K minKey) Returns a view of the portion of the map whose keys are greater than or equal to mi ...
bucketa costly operation. You need to consider the load factor and the initial capacity when creating the hash map, be aware of ...
The expected maximum size is a hint for the initial capacity of the map, but its exact effects are not specified. 21.8.4. WeakHa ...
«
19
20
21
22
23
24
25
26
27
28
»
Free download pdf