I have gone through this link; but I am getting confused with the following sample code:-
public class NullTest {
public static void method(Object obj){
System.out.println("method with param type - Object");
}
public static void method(String str){
System.out.println("method with param type - String");
}
public static void method(StringBuffer strBuf){
System.out.println("method with param type - StringBuffer");
}
public static void main(String [] args){
method(null); //... compile-time error!
}
}
Error that I am getting is :-
ankit@stream:/home/Data/JAVA/practice$ javac trickyMethodOverloading.java
trickyMethodOverloading.java:16: error: reference to method is ambiguous, both method method(String) in trickyMethodOverloading and method method(StringBuffer) in trickyMethodOverloading match
method(null); //... compile-time error!
Any suggestions, please