Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

String Vs Object  RSS feed

 
Pandurangan Rakesh
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have the following program

Now when i compile and run the program alweays the method show() with String parameter is called i.e the output is always String null and never Object null.Can u tell me why?
[ June 06, 2004: Message edited by: Carl Trusiak ]
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37222
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pandurangan,
Since String is a subclass of Object, it gets called. Java calls the method with the most specific parameter.
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this to Beginner
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!