Hi all,
Please check this.I have to overloaded methods like this..
----------------------------------------------------------------------------
public void method(Integer i){
System.out.println("Integer version");
}
public void method(
String s){
System.out.println("String version");
}
----------------------------------------------------------------------------
And i'm invoking method like this:- method(null);
It gives me following error:-
reference to method is ambiguous, both method method(java.lang.String) in
test and method method(java.lang.Integer) in test match
----------------------------------------------------------------------------
But , suppose i change methods like this
public void method(Integer i){
System.out.println("Integer version");
}
public void method(Object o){
System.out.println("Object version");
}
----------------------------------------------------------------------------
It compiles and gives output :- "Integer version"
I thought , it will be same compiler - error?Could you please explain , why it is so?
[ December 19, 2006: Message edited by: Barry Gaunt ]