public class Exer {
public static void main(String[] args) {
Base1 b1 = new Sub1();
b1.add(1,2,3);
}
}
class Base1{
public void add(int a, int... arr){
System.out.println("Base1");
}
}
class Sub1 extends Base1{
public void add(int a, int[] arr){
System.out.println("Sub1");
}
}
输出结果:
Sub1
结论:属于重写!在参数列表里,编译器认为int... arr和int[] arr是相同的。
标签:...,arr,Sub1,int,面试题,Base1,public From: https://www.cnblogs.com/dequanth/p/16725374.html