This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overloading the methods with Object and String

 
thomas davis
Ranch Hand
Posts: 207
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic