Generics FAQ

I think I’m not alone when I count myself amoung the generics newbies… so when a co-worker found this Generics FAQ I thought I would pass it along…

http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html

When you get compiler errors like: “capture of ? extends T does not apply to…blah blah” and you just want someone to shoot you, first try the above FAQ and you might save yourself a painful bullet wound.

In Eclipse i run into stuff like:

capture of ? extends T does not apply to capture of ? extends T

While they’re equal…

I can’t help but wonder why the standard rules in Java are not copied in the handling of Generics…

Thing thing = ...; // can be a Thing, or a subclass of Thing, easy as that

but with generics you go

List<? extends Thing> things = ...;
List<Thing> things = ...;
// and what-not

unbound, upperbound, lowerbound wildcards, etc… This is just funny…[quote]Which methods that use the type parameter as upper wildcard bound in a parameterized argument or return type are accessible in a wildcard instantiation?
[/quote]
Is that a Frequently asked question? really? I can hardly pronounce it :slight_smile:

Oooh, i’m hijacking a thread! ;D

It’s a good FAQ, but I aint gonna read it :slight_smile: