File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we super in class type

 
Rajesh k Jha
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 537
Eclipse IDE Java Python
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Type declarations cannot have super or wildcards<?> class or method both.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is illegal. Give me an example where it could be useful. Only with wildcard "super" is legal.
 
Nitish Bangera
Ranch Hand
Posts: 537
Eclipse IDE Java Python
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
legal ok but not for declaring types for the class and methods.
 
Rajesh k Jha
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic