TestOverload.class
public class TestOverload {
public void test(int a,int...x){//数组 int[] x={1,2,3,4,5,6}; //动态参数列表前面可以加东西,后面不可以
System.out.println("执行了test方法携带动态列表");
for(int i=0;i< x.length;i++){
System.out.println(x[i]);
}
}
// public void test(int...x){//数组 int[] x={1,2,3,4,5,6};
// System.out.println("执行了test方法携带动态列表");
// for(int i=0;i< x.length;i++){
// System.out.println(x[i]);
// }
// }
//与相同意义的数组类型的方法构成重载 本质是一样的
//动态参数列表的方法可以不传递参数 相当于0个
//数组的方法必须传递参数
// public void test(int[] array){
//
// }
public void test(){
System.out.println("执行了test方法没有携带参数");
}//没有参数执行
// public void test(boolean b){
// System.out.println("执行了test方法带boolean参数"+b);
// }
// public void test(int i){
// System.out.println("执行了test方法携带int参数"+i);
// }
// public void test(String s){
// System.out.println("执行了test方法携带int参数"+s);
// }
public static void main(String args[]){
//1.创建对象
TestOverload to=new TestOverload();
// to.test(1,2,3,4,5);
// to.test('a');//方法传递 类型之间的转化问题
to.test(1,2,3,4,5);
//2.通过对象方法名字 调用方法 可以直接通过方法名字定位方法
//如果方法名字一直 通过方法的参数列表类型来定位方法
}
}



