C# in Depth

Cover of C# in Depth
Order now (3rd edition)

Java's interesting approach to generics

Chapter 3: Parameterized typing with generics: 3.6.5

Created: 2/22/2008
Last updated: 2/22/2008

Java's approach to generics is interesting, partly because the variance which is available is at the call site, not the declaration. Neither Eric nor I know of languages which take a similar approach.

In some ways, Java's support for generics is similar to the support for checked exceptions: the exceptions are only checked in the compiler, not in the runtime. It would be perfectly possible to write a pseudo-Java compiler which didn't care about checked exceptions.