Is there any specific reason why Java uses early binding for overloaded methods? Wouldn't it be possible to use late binding for this?
Example:
public class SomeClass {
public void doSomething(Integer i) {
System.out.println("INTEGER");
}
public void doSomething(Object o) {
System.out.println("OBJECT");
}
public static void main (String[] args) {
Object i = new Integer(2);
Object o = new Object();
SomeClass sc = new SomeClass();
sc.doSomething(i);
sc.doSomething(o);
}
}
Prints: OBJECT OBJECT
I would rather expect: INTEGER OBJECT