What will be the result of compiling and running the following code?

public class Main { 
    public static void var(int... x)      //1
        System.out.println("int... x"); 
    public static void var(Object... x)  //2
        System.out.println("Object... x"); 

    public static void var(Integer... x) //3
    public static void main(String... args)
        int i = 0; 
        Integer i2 = 127; 
        var(i, i2); 
Compilation error: ambiguous method. It is unclear, which method shoud be called: should fist argument be boxed into Integer or the second one unboxed to it's int value.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Sign Up Now
or Subscribe for future quizzes