Category: Overriding Methods from Non
-
Modifying Capacity – Collections, Part I: ArrayList
•
Modifying Capacity The following two methods can be used to modify the capacity of a list. There is no method that returns the current capacity of an ArrayList<E>. void trimToSize() Trims the capacity of this list to its current size. Click here to view code image void ensureCapacity(int minCapacity) From List<E>interface. Ensures…
-
Wildcard Capture – Generics
•
11.9 Wildcard Capture As we have seen, a wildcard can represent a family of types. However, the compiler needs to have a more concrete notion of a type than a wildcard in order to do the necessary type checking. Internally, the compiler represents the wildcard by some anonymous but specific…