File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes String Vs Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String Vs Object" Watch "String Vs Object" New topic

String Vs Object

Pandurangan Rakesh

Joined: Jun 06, 2004
Posts: 24

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

Joined: May 26, 2003
Posts: 32819

Since String is a subclass of Object, it gets called. Java calls the method with the most specific parameter.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
I'm moving this to Beginner
I agree. Here's the link:
subject: String Vs Object
It's not a secret anymore!