Java is being augmented with a library of interfaces and classes.
Already there are several abstractions in the library that
would be more useful if parameterization were available.
Types such as
Enumeration are most naturally written as
parameterized types, but currently manipulate objects of type
This has two unfortunate consequences:
intthen it is necessary to objectify them. For example,
intmust be explicitly wrapped in an
Integerobject to make it usable as an
Object. This wrapping step is awkward for the programmer and has runtime overhead.
Vectoror produced by an
Enumeration, it must be explicitly cast from
Objectto the expected type. If the element has a primitive type, it also must be unwrapped after the cast, adding even more cost and coding complexity.
Both problems are ameliorated by parameterized types. When elements are added, there is no need to objectify them, and when they are retrieved from the collection, there is no need for the expensive runtime cast or unwrapping.