Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we super in class type

 
Rajesh k Jha
Ranch Hand
Posts: 72
  • 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
  • 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
  • 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
  • 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
  • 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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic