• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java null  RSS feed

 
manjit singh thakurratan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have encountered a program which confused me ....
its something like the below


What is the output of the program? I got this is Integer as output... I dunnoh how? I was expecting this is Object.

Could someone help me ....

Regards
 
Yogesh Gnanapraksam
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why? I also want to know...
If i change the first method's defintion to accept String object ,it gives me compile time error that
"meth1(Stringl) is ambiguous for type overload"
 
Devaka Cooray
Marshal
Posts: 5652
765
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manjit, please UseCodeTags when you post a source code in future. I've added the code tags on your post for you.

Regarding your question, please have a look at this topic
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Integer and Object both can accept null . but Integer is near in Object hierarchy[xxxx extends Integer extends Object...] . so method which has Integer parameter get called . also String and Integer both are in same level in Object hierarchy so *meth1(Stringl) is ambiguous for type overload* compiler error

hth
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do a search on "most specific" and you will find several threads with the answer.
 
manjit singh thakurratan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yeah i got .. it
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!