Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String Vs Object

 
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
Marshal
Posts: 34672
367
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic