| Author |
Runtime / Compile Time Behaviour
|
Grant Malcom
Greenhorn
Joined: Nov 27, 2009
Posts: 1
|
|
Hi, EveryBody
Here is the Code , for Which i need some Explanation....
Now I get a Compile Error, at line# 13, Also, when the Method print with Integer Parameter is commented, then Program runs Fine, printing - String!, ( Why Not Object! was Printed )
Can Any one Explain the Behavior, is it anything to do with Runtime Polymorhisim.
Thanks in Advance!
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
|
wait....letme give you a link which will explain it to you
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
|
http://faq.javaranch.com/java/ScjpFaq#mostSpecific
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
so this means that between String and object, String will be chosen as String extends object....now even Integer extends Object so now compiler is confused whether to chose String or Integer so you get an ambiguous error
i hope this clears it all
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
sorry
its
http://faq.javaranch.com/java/ScjpFaq#mostSpecific
|
 |
 |
|
|
subject: Runtime / Compile Time Behaviour
|
|
|