File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes generic class declaration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "generic class declaration" Watch "generic class declaration" New topic

generic class declaration

Serg Masow
Ranch Hand

Joined: Dec 17, 2007
Posts: 50

can anyone tell me why

class Test<T extends Number> {}

is perfectly legal, but

class Test<T super Number> {}


SCJP 6.0 [95%] OCE EJBD 6.0 [93%]
Kelvin Chenhao Lim
Ranch Hand

Joined: Oct 20, 2007
Posts: 513
Hi Serg,

Welcome to Javaranch. Basically, the issue here is that Java does not allow lower bounds for type parameters, i.e. "<T super Foo>" is always invalid syntax. It does allow lower bounds for wildcards, e.g. "<? super Foo>".

You may want to check out this other thread from last week where we briefly discussed this same issue.

SCJP 5.0
Serg Masow
Ranch Hand

Joined: Dec 17, 2007
Posts: 50
Hi Kelvin,

many thanks for your answer and the link.
I agree. Here's the link:
subject: generic class declaration
It's not a secret anymore!