• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

generics - difference b/w <? extends A> and <T extends A>??

 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the difference between saying

1) <? extends A> and
2) <T extends A>? (where A is some class)

1 means 'anything' that extends A

2 means 'T' where 'T' extends A

Both sound the same! What is the difference?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Both sound the same! What is the difference?



We need some context. Show us some compilable code.

Henry
 
Aakash Goel
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

Both sound the same! What is the difference?



We need some context. Show us some compilable code.

Henry



I dont know. I am confused. I was just referring to the general meaning of these statements.
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aakash Goel wrote:I dont know. I am confused. I was just referring to the general meaning of these statements.



Both cases have different uses... so it is difficult to compare the "general meaning". The second case is use to bound a Type when you declare a type T (as either a class type or a method type). The first case is a bounded wildcard, which can be used when declaring a generic typed class. Of course, this can get complicated, which is why we need context...

Henry
 
reply
    Bookmark Topic Watch Topic
  • New Topic