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 Creating own generic types 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 "Creating own generic types" Watch "Creating own generic types" New topic
Author

Creating own generic types

Maheswaran Devaraj
Ranch Hand

Joined: Sep 14, 2007
Posts: 47
Hi friends,



can we use super keyword instead of extends in the line 1.

Thanks in advance,
Mahes
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

What happened when you tried? What do you think it would mean if you would use 'super' instead of 'extends' there?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Deepak Giri
Ranch Hand

Joined: Feb 12, 2009
Posts: 52
Hi Maheswaran!

well, you can use super but for that you got to have a reason ( i mean you got to have some superclass which is extended or implemented by Animal directly or indirectly)..

if you replace the extends word with super in line 1 here, then you cannot declare an AnimalHolder reference (here, in line 4) which is of the type Dog, because Dog is not the supertype of Animal


SCJP
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Creating own generic types
 
Similar Threads
generics
"T extends Animal" VS "? extends Animal"
what is the difference in E and T?
Creating Generic Classes
Generics - Super type parameters