This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating own generic types

 
Maheswaran Devaraj
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you tried? What do you think it would mean if you would use 'super' instead of 'extends' there?
 
Deepak Giri
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic