*
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
Author

generic class declaration

Serg Masow
Ranch Hand

Joined: Dec 17, 2007
Posts: 49
Hello,

can anyone tell me why

class Test<T extends Number> {}

is perfectly legal, but

class Test<T super Number> {}

not?


SCJP 6.0 [95%] OCP 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: 49
Hi Kelvin,

many thanks for your answer and the link.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: generic class declaration
 
Similar Threads
Problem in Generics
Generics doubt
generics
how to use generic in this case
Wildcard