Ambiguity Error.
posted 14 years ago
this code show compilation error(ambiguity), this is absolutely fine.
But, the following code doesn't show any error while compiling(How java can allow this, any one to justify this).
Thanks,
Bennet.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
this code show compilation error(ambiguity), this is absolutely fine.
But, the following code doesn't show any error while compiling(How java can allow this, any one to justify this).
Thanks,
Bennet.
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
The compile will always use the most specific arguments. Since String is more precise that Object that method is chosen.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Bennet Xavier
Ranch Hand
Posts: 162
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
How can you say, that "most specific arguments" for a null.
If you say this, it must work for other code also.
This is what i thought, but its not actual reason i suppose.
Thanks,
Bennet
If you say this, it must work for other code also.
This is what i thought, but its not actual reason i suppose.
Thanks,
Bennet
posted 14 years ago
-
2 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
With String and Object, you can say that String is more specific than Object because it is a subclass of Object.
How do you decide which is more specific between String and A ? You can't and neither can the compiler and so it complains.
How do you decide which is more specific between String and A ? You can't and neither can the compiler and so it complains.
Joanne
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
There is a lot about "overloading" in the Java™ Language Specification; read that section and go to the index and look up overloading, and see what you can find.
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hello,
This is the "Automatic promotion" concept of OOPS. Here String and the class A both are at same level. that means both are extending the Object class.that is why you got error in first program. Coming to the second program, you used String and Object class references as parameters. here the compiler always check for String first, If it is not matched then it will go for Object class reference. I hope you got my point.
This is the "Automatic promotion" concept of OOPS. Here String and the class A both are at same level. that means both are extending the Object class.that is why you got error in first program. Coming to the second program, you used String and Object class references as parameters. here the compiler always check for String first, If it is not matched then it will go for Object class reference. I hope you got my point.
Regards,
Radhakrishna
| I am mighty! And this is a mighty small ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |








