• 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 - method declarations -from Examlab

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Source: Examlab for SCJp 1.6 - Diagnostic Exam - Question 57




For the above code, I do not quite fully understand why the below two method declarations compile.

public abstract <K> A<? extends Number> useMe(A<?super K>);

public abstract <K> A<? super Number> useMe(A<?extends K>);



Is it because in <? super K> and <? extends K>, the 'K' refers to the 'K' in the CLASS declaration ?
If so, then A<?super K> may still fail the class declaration evaluation of <K extends Number>.
Is that possibility just ignored ?
 
Ranch Hand
Posts: 1032
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This forum has a Search functionality which can come in quite handy.

This thread (which is just a few posts below this one) has some discussion about this.
 
Clay Chow
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey,

Thanks.
I did do some searches, based on the code statements.
I guess it doesn't search through that.
 
Ruben Soto
Ranch Hand
Posts: 1032
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem. What I usually do is try the most distinct string in the question. In this case I would search for useMe, and see of you have luck with it. I don't think the search engine allows you to search for exact sentences including them into double quotes, which is dumb.
 
reply
    Bookmark Topic Watch Topic
  • New Topic