Table of contents
Generics in Java 5
Lots of New Language Features in Java 5…
The new features work together…
How did that work?
How does it work now?
Common operations are now typesafe
Customise Collection Classes
Customise Collection Classes (continued)
Reveal implicit type requirements of interfaces
Add control over argument validation
Add control over argument validation (continued)
But Java has always been able to do that!
Arrays are covariant
Covariance requires RTTI
Generics can’t have RTTI
So generic classes can’t be covariant
How will we do without covariance?
How will we do without covariance? (continued)
Using a wildcard type restricts access
Using a wildcard type restricts access (continued)
Bounded wildcards can work together
Bounds work with type variables too
Erasure produces some surprises
Erasure produces some surprises (continued)
Author: Maurice Naftalin