*** If opportunity doesn't knock, build a door !! ***
I hope that wasn't a tauntThere are about 7 hits if you open the Java Language Specification and use ctrl-F-“overload”
*** If opportunity doesn't knock, build a door !! ***
I read it in a way which made me feel you were suggesting that I could just look up the answer in the JLS instead of asking. My Bad !use ctrl-F-“overload”
*** If opportunity doesn't knock, build a door !! ***
Mandy Singh wrote:Right. I somehow overlooked the fact that the var-args would be translated into an array.
I read it in a way which made me feel you were suggesting that I could just look up the answer in the JLS instead of asking...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
These parameters make the method call ambiguous again even though the one with 'byte... x' is more specific.
Campbell Ritchie wrote:bytes being smaller than longs are more specific, but only a byte can fit into a byte[], so the ambiguity can be sorted out.
*** If opportunity doesn't knock, build a door !! ***
Winston Gutkowski wrote: Now, most of the guys (and gals) here are good, but we do make mistakes from time to time...
Winston
*** If opportunity doesn't knock, build a door !! ***
Tony Docherty wrote: When I added empty method bodies it compiled on my system - what version of Java are you using and can you show the whole compiler error message.
D:\java_practice>javac Test.java
Test.java:13: reference to go is ambiguous, both method go(byte...) in Test and
method go(long...) in Test match
go(b);
^
1 error
Campbell Ritchie wrote:Don’t know any more. Sorry. Have you tried casting a byte[] to a long[]? Does that compile at all?
*** If opportunity doesn't knock, build a door !! ***
Sure... the code that I am trying to compile is...
Tony Docherty wrote:The reason passing a byte value doesn't work (whereas passing a long does work) was explained by Campbell earlier.
...it is said that bytes being smaller than long are more specific so the ambiguity can be sorted out.Campbell Ritchie wrote:Passing a long[] to a byte[] is impossible, so that sorts out the ambiguity; bytes being smaller than longs are more specific, but only a byte can fit into a byte[], so the ambiguity can be sorted out.
*** If opportunity doesn't knock, build a door !! ***
But that is not the question. My question is, why passing a 'byte' causes ambiguity (even when byte is more specific than long) ?
Consider Paul's rocket mass heater. |