Method Overloading for NULL parameter
Posted
by
Phani
on Stack Overflow
See other posts from Stack Overflow
or by Phani
Published on 2011-03-08T07:55:21Z
Indexed on
2011/03/08
8:10 UTC
Read the original article
Hit count: 239
I have added three methods with parameters:
public static void doSomething(Object obj) {
System.out.println("Object called");
}
public static void doSomething(char[] obj) {
System.out.println("Array called");
}
public static void doSomething(Integer obj) {
System.out.println("Array called");
}
When I am calling doSomething(null) , then compiler throws error as ambiguous methods. So Is the issue because Integer and char[] methods or Integer and Object methods?
© Stack Overflow or respective owner