I tried to understand how overloaded methods are invoked using transformations. Let me explain my question with an example that I am trying
public class Autoboxing {
public void meth(Integer i){
System.out.println("Integer");
}
public void meth(long i){
System.out.println("Long");
}
public void meth(int... i){
System.out.println("int");
}
public void meth(Object i){
System.out.println("Object");
}
public static void main(String[] args) {
Autoboxing box= new Autoboxing();
box.meth(5);
}
}
Here's the conclusion: Long
Why is the method with the argument long called instead in the Wrapper Integer. Please explain.
source
share