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

Why THIS output?

 
Yohan Shikari
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class AQuestion
{
public void method(Object o)
{
System.out.println("Object version");
}

public void method(String s)
{
System.out.println("String Version");
}

public static void main (String args[])
{
AQuestion question = new AQuestion();
question.method(null);
}

}

In the above code: the output is "String Version"
Why is it so?

Why NOT "Object version"

Pls explain
 
Raghu Shree
Ranch Hand
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
String is more specific then Object. So it calls String arguments version.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic