Java可变参数


Java传递可变参数如下

    public static void main(String[] args) {
        //Demo07 demo07=new Demo07();
        //demo07.test(1,2,3,4,5,6,7,8,9,10);
        test(1,2,3,4,5,6,7,8,9,10);
        test(new int[]{1,2,3});
    }

    public static void test(int... i) {
        for (int j = 0; j < i.length; j++) {
            System.out.println(i[j]);
        }
    }