aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes overloading generic methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "overloading generic methods" Watch "overloading generic methods" New topic
Author

overloading generic methods

Mike Mitchell
Ranch Hand

Joined: May 28, 2008
Posts: 38
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 ]

SCJP 5, SCWCD 5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: overloading generic methods