• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Overload resolution issue

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could someone explain how java compiler work in this situation?


 
Vladimir Yatsevskiy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
P.S. i know about this rules.
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vladimit. Welcome to the Ranch!

When there are more than one method that can match a method call, the exact rules for determining precedence are a bit nasty. You can read part 15.12.2.5 of the Java Language Specification for the full details.

(Edit: posted before your second message)

But briefly, in the first example there's a rule that can be applied to decide that f(int, Integer) shoud be applied. It's more specific than f(long, Integer) because the first parameter is actually an int. The rules as defined don't give a way of deciding between the two methods in your second example.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

For all j from 1 to n, Tj <: Sj.


This bit from the rules, roughly speaking, says that a method is more specific if all its parameters are at least as specific (and at least one is more specific). It doesn't try to cope with the situation where some are more specific and some less specific.
 
Vladimir Yatsevskiy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Matthew Brown wrote:Hi Vladimit. Welcome to the Ranch!

.



Thanks. actually my name is Vladimir. I sent request for fix this misprint. thanks for you answer.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic