Re: More questions about generics
Daniel Pitts wrote:
class GlosseryTerm extends GlosseryEntry {
List<String> l; // Use generics here too!
}
class GlosseryEntries<T extends GlosseryEntry> {
List<T> entries;
}
class GlosseryTerms<T extends GlosseryTerms> extends GlosseryEntries<T> {
}
A work of art, both as code and as an example.
There seems to be no way around the twistedness of generics thinking, and no
end to its effectiveness when you get it right.
The Rosetta Stone for generics seems to be that generified types don't inherit
naively - you have to play with the 'extends' and 'super' keywords in the
formal type parameters. Well, part - another part is to satori-ize the
interactions between compile-time generic type safety and run-time generic
type erasure.
<http://java.sun.com/docs/books/tutorial/extra/generics/wildcards.html>
<http://java.sun.com/docs/books/tutorial/extra/generics/morefun.html>
<http://java.sun.com/docs/books/tutorial/extra/generics/literals.html>
--
Lew