Java方法
可变参数: 用于方法参数不确定。可变参数的本质上是数组
注意:方法中可变参数只能有一个,如果方法中有多个参数,可变参数放到最后
public static void main(String[] args) {
        System.out.println(unKnowNums(1, 2, 3, 4, 5, 6, 7, 8, 9)); //45
    }
    public static int unKnowNums(int x, int ... y) {
        int sum = x;
        for (int i = 0; i < y.length; i++) {
            sum += y[i];
        }
        return sum;
    }
方法重载: 方法修饰符,返回类型,方法名一样,参数不同。
参数不同:
1、参数数量相同,参数类型不同
2、参数数量不同
    public static void unKnow(int x) {
    }
    public static void unKnow(int x, int y) {
    }
    public static void unKnow(int x, String y) {
    }
    public static void unKnow(String x, String y) {
    }
 
                    
                 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号