1.形式:类型...(相当于数组类型)
2.用法:
public class Test {
public static void main(String[] args) {
System.out.println("lllllllllhello");
person ps = new person();
ps.setNames("li","wang");//输入两个数据
//System.out.println(ps.getNames()); 这样是打印不出数据的
System.out.println(Arrays.toString(ps.getNames()));
ps.setNames("li","wang","le");//输入三个数据
System.out.println(Arrays.toString(ps.getNames()));
ps.setNames();//输入零个数据
System.out.println(Arrays.toString(ps.getNames()));
}
}
class person{
private String[] names;
public void setNames(String... names){
this.names=names;
}
public String[] getNames(){
return this.names;
}
}
2.输出结果: