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 Creating own generic types 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 "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: 15092

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 8 API documentation
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
It's not a secret anymore!