[jdom-interest] JDom and Java5

Gregor Zeitlinger gregor at zeitlinger.de
Sat Feb 23 09:34:34 PST 2008

On Sat, Feb 23, 2008 at 3:51 PM, Rolf <jdom at tuis.net> wrote:
>  As for Mattias's original claim that List<?> can be cast to
>  List<Element> if you know the content will be only Elements, then, I
>  believe that lends a certain weight to List<?>, but, is the same not
>  true for List<Object>?
Yes, all of the discussed variations can be cast, but not all are
equivalent (see below).

>  Does this make sense?
I think this is (yet another) design flaw of Java generics.

1) List: this is pre-generics legacy code
2) List<?>: this construct should have been disallowed, as it's
equivalent to List<? extends Object>
3) List<Object>: a list where objects can be read and written
4) List<? extends Object>: a list where can be read only

Gregor Zeitlinger
gregor at zeitlinger.de

More information about the jdom-interest mailing list