• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

overloading generic methods

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys. I have two questions about generic method overloading.

With regard to this code:



(a) When methods 1 and 3 are commented in, compiler complains about 'call 2', presumably because Number implements Comparable. If I comment out 'method 1', the compiler chooses the method with the narrower upper bound. Is there a rule about overloading generic methods to be deduced from that? Does this have something to do with 'covariance'?

(b) When methods 3 and 4 are commented out the autoboxing of calls 2 and 3 works fine, however when 3 and 4 are in (and method 1 out per a), call 2 fails with:



and call 3 with:



If I explicitly box them myself it works as expected. That seems strange to me.

Thanks.
[ June 21, 2008: Message edited by: Mike Mitchell ]
 
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic