Q:

Method Call Order

The following code compiles fine in Java:
public static void main(String[] args) {
    int i =5;
    call(i);
}

static void call(int i){
    System.out.println("int");
}

static void call(long i){
    System.out.println("long");
}

static void call(Integer i){
    System.out.println("Integer");
}

static void call(Object i){
    System.out.println("Object");
}

But the following code gives compile time error:
public static void main(String[] args) {
    int i =5;
    call(i);
 }

static void call(int... i){
    System.out.println("int...");
}

static void call(long... i){
    System.out.println("long...");
}

static void call(Integer... i){
    System.out.println("Integer...");
}

static void call(Object... i){
    System.out.println("Object...");
}

Why the similar call mechanism is not maintained by Java while working with var-args? In the second example also, the call should go to method static void call(int... i)

A:

The link given by @NilsH explains the reason clearly. Please find the details at
http://www.xyzws.com/Javafaq/why-overloading-a-varargs-method-doesnt-work-for-the-primitive-type-and-its-object-wrapper-type/50

