In this piece of code, why the compiler is not able to reference the method that has varargs argument from static context.
private static void doSomething(int... nums) {
System.out.println("1");
}
private void doSomething(int num1, int num2) {
System.out.println("2");
}
public static void main(String[] args) {
doSomething(1,2);
}
JDK 17正在抱怨Cannot make a static reference to the non-static method doSomething(int, int)
.这是一个bug还是另一个我不知道的特性.
JDK 8和JDK 11不要对此抱怨!