wood burning stoves 2.0*
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String Vs Object" Watch "String Vs Object" New topic
Author

String Vs Object

Pandurangan Rakesh
Greenhorn

Joined: Jun 06, 2004
Posts: 24
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30116
    
150

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


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
I'm moving this to Beginner
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: String Vs Object
 
Similar Threads
mock exam question
Overloading Example doubt
(MyClass) null
Overloading question...
What's in new String() object?