This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one 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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Creating own generic types" Watch "Creating own generic types" New topic

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,
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114

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

I agree. Here's the link:
subject: Creating own generic types