This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Can we super in class type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Can we super in class type" Watch "Can we super in class type" New topic
Author

Can we super in class type

Rajesh k Jha
Ranch Hand

Joined: May 10, 2009
Posts: 72
class Pie<T super Apple>{
Can we super in class type?
I am having doubt on it and nowhere i found whether i can or not. I know its a simple one, but i need to know this.
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

Type declarations cannot have super or wildcards<?> class or method both.


[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

It is illegal. Give me an example where it could be useful. Only with wildcard "super" is legal.


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

legal ok but not for declaring types for the class and methods.
Rajesh k Jha
Ranch Hand

Joined: May 10, 2009
Posts: 72
Thanks to all, now i got that <T super ..> cant be used with class type
and <?> cant be used with Generic method and Class declaration type...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can we super in class type
 
Similar Threads
Generic declarations "? super" Vs. "? extends"
map is an ArrayList, compiler knows that Object is superclass of ArrayList, yet does nothing?
Static Method Inheritance
generics Strike again !!!
private constructor inSuper Class?