This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Overloading the methods with Object and String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Overloading the methods with Object and String" Watch "Overloading the methods with Object and String" New topic
Author

Overloading the methods with Object and String

thomas davis
Ranch Hand

Joined: Feb 01, 2003
Posts: 207
When I ran the following code by passing null as a parameter ,which method will get executed and why does not it take null as parameter?If any other object passed what could be the possible result?
After running this code snippet,I got a error as given below:
TestOverLoadinObject.java:20: cannot resolve symbol
symbol : method aMethod1 (java.lang.Object)
location: class TestOverLoadinObject
objTestOverLoadinObject.aMethod1(obj);
^

class OverLoadinObject
{
void aMethod1(Object obj)
{
System.out.println("Here from object!!"+obj);}
void aMethod1(String str)
{
System.out.println("Here from String!!"+str );
}
}
public class TestOverLoadinObject
{

public static void main(String[] args)
{
TestOverLoadinObject objTestOverLoadinObject = new TestOverLoadinObject();
Object obj = null;
objTestOverLoadinObject.aMethod1(obj);
}
} :roll:
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Follow up here. Please stop posting duplicates of the same question in different places; it's more work for us to sort through them.


"I'm not back." - Bill Harding, Twister
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Overloading the methods with Object and String
 
It's not a secret anymore!