Java Reference
In-Depth Information
scribe Properties in more detail since you are more likely to actually
need to write code that uses it.
21.15.1. Enumeration
Enumeration<E> is analogous to Iterator , but has just two methods:
hasMoreElements which behaves like hasNext , and nextElement which be-
haves like next . You can get an Enumeration that iterates through a non-
legacy collection from the static method Collections.enumeration .
You can convert an Enumeration to a List via the static Collections.list
method, which returns an ArrayList containing all the elements access-
ible by the enumeration, in the order the enumeration returned them.
Exercise 21.6 : Rewrite the example program Concat on page 528 so
that it uses an implementation of Enumeration that has only one FileIn-
putStream object open at a time.
21.15.2. Vector
The Vector<E> class is analogous to ArrayList<E> . Although Vector is a leg-
acy class, it has been made to implement List , so it works as a Collec-
tion . All methods that access the contents of a Vector are synchronized.
As a legacy collection, Vector contains many methods and constructors
that are analogous to those of ArrayList , in addition to those it inherits
from List . The legacy constructors and methods of Vector and their ana-
logues in ArrayList are
public Vector(int initialCapacity, int capacityIncrement)
No analogue. Creates a new Vector with the given initialCa-
pacity that will grow by capacityIncrement elements at a time.
public Vector(int initialCapacity)
 
Search WWH ::




Custom Search