I have a behaviour that I don't understand with overloading in Java.
Here is my code:
interface I {} class A implements I {} class B { public void test(I i) {} public void test (A a) {} } When I call the following line:
I a = new A(); b.test(a); I thought the called method would be test(A) but visibly it's test(I).
I don't understand why. In runtime my variable a is a A even A inherits I.
awill be aAor something else (it might depend on user input for example). What is sure is thatawill be aI.