why primitive type will call first rather than wrapper classes?
- by kandarp
Hello EveryOne,
public class A {
public void test(Integer i) {
System.out.println("In Wrapper Method");
}
public void test(int i) {
System.out.println("In primitive Method");
}
public static void main(String args[]) {
A a = new A();
a.test(5);
}
}
When I will call test method from main and pass integer argument, then it will call the method which accept primitive type as argument. I just want to know that why it call primitive type method rather than the method who accepts wrapper class as argument? Is there any rule, which java follow to call methods?
Thanks,