以前在C#中知道有可变长参数这一说法,后来发现C/C++中也有。
最近由于用java,发现在1.5版本以后也有了这个概念。
实例如下,简单用法估计也就这样吧^-^:
public class VarPDemo{
  public static void main(String[] args){
    System.out.println("begin to demo------>");
    demo("aaa","ccc");
    demo("sss","ddddd","ddddd");
    System.out.println("end to demo------->");
  }
  public void demo(String... args){
    for(String s : args){
      System.out.println(s);
    }
  }
}
说明一下,变长参数一定要放在最后面,这个是毋庸置疑的!

相关文章:

  • 2021-06-16
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
猜你喜欢
  • 2021-07-02
  • 2022-12-23
  • 2021-10-26
  • 2022-02-11
  • 2021-06-10
  • 2022-12-23
  • 2021-07-11
相关资源
相似解决方案