• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Runtime / Compile Time Behaviour

 
Grant Malcom
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wait....letme give you a link which will explain it to you
 
Ankur kothari
Ranch Hand
Posts: 531
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 531
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic