Results 1 to 4 of 4
Thread: Need clarification..New to java
- 06-02-2011, 09:02 AM #1
Member
- Join Date
- May 2011
- Posts
- 22
- Rep Power
- 0
Need clarification..New to java
I have overloaded a method (here it is "testMethod") with one version talking String as argument and another taking as Object. Now when I invoke testMethod() with null as parametre, the one with String argument is called. Can anyone explain why "testMethod(String s)" instead of "testMethod(Object s)" ? (null doesn't pass instance of test with string)
public static void main(String[] args)
{
testMethod(null);
}
static void testMethod(String s)
{
System.out.println("this is string");
}
static void testMethod(Object s)
{
System.out.println("this is object");
}
- 06-02-2011, 11:48 AM #2
There was a good discussion over velocityreviews about the same. That will help you out. Read it fully here : difference between null object and null string
Hope that helps,
GoldestJava Is A Funny Language... Really!.gif)
Click on * and add to member reputation, if you find their advices/solutions effective.
- 06-02-2011, 12:55 PM #3
- 09-08-2011, 08:55 AM #4
Member
- Join Date
- May 2011
- Posts
- 22
- Rep Power
- 0
Similar Threads
-
Clarification on main method
By Hype in forum Advanced JavaReplies: 5Last Post: 02-17-2011, 06:49 AM -
Struts Clarification
By vinothkumarrvk in forum Web FrameworksReplies: 0Last Post: 02-26-2010, 02:24 PM -
need clarification in this statement.
By Unsub in forum New To JavaReplies: 5Last Post: 02-26-2010, 01:16 PM -
HELP! need clarification
By ptsofathrty in forum New To JavaReplies: 1Last Post: 12-16-2008, 08:02 AM -
Private Classes Clarification
By justlearning in forum New To JavaReplies: 1Last Post: 05-06-2008, 10:51 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks