Wednesday 12 March 2008

Java Generics

I think the The Craftsman 44: Java Generics 2 gives the best exaplaination on when to use extends or super when defining Generics.

Basically use

you can widen the type of a list by using ? extends X, only if you
plan on reading from that list

and

If you plan on writing to that list, use

No comments: