please help me explain this code behaviour:
public class Main {
public static void var(Object... x) {
System.out.println("Object");
}
public static void var(Integer... x) {
System.out.println("Integer...");
}
public static void main(String... args) {
byte i = 0;
Integer i2 = 127;
var(i, i2);
}
}
code above returns Object...
public class Main {
public static void var(Object... x) {
System.out.println("Object");
}
public static void var(int... x) {
System.out.println("int...");
}
public static void main(String... args) {
byte i = 0;
Integer i2 = 127;
var(i, i2);
}
}
java: reference to var is ambiguous, both method var(java.lang.Object...) in inheritanceTest.Main and method var(int...) in inheritanceTest.Main match
I have these questions.
- Why each code variant Do returns corresponds value
- What principical differencies between these code snippets.
Really I cannot understand this part of jls a lot of time. My colleagues don't know it too.