Enumeration interface

The output from this program is.shown here:

Initial size: 0
Current capacity: 9
First element: 1
Last element: 2
Vector contains: 3

Elements in vector:

With the release of Java 2, Vector adds support for iterators. Instead of relying o!” an enumeration to cycle through the objects (as the preceding program does), you now can use an iterator. For example, the following iterator-based code can be substituted into the.program: Because enumerations are not recommended for new code, you will usually use an , iterator to enumerate the contents of a vector. Of course, much legacy code exists that employs enumerations.Fortunately, enumerations and iterators work in nearly the ,same manner

[vfb id=1]

Share This