阅读(853) (1)

...

2019-06-27 09:59:43 更新

... 用于构建函数时使用,要在参数列表的最后一个且只能有一个,实参在传入时可以不传,也可以传多个。

public void print(int i, int j, String... m) {
    System.out.print(i + " " + j + " ");
    for(String str : m) {
        System.out.print(str + " ");
    }
    System.out.println();
}


//调用:
new A().print(1, 2);
new A().print(1, 2, "a", "abc");