java 传参数时 类型后跟 3个点 “...” 的意义
来源:互联网 发布:旬牙利算法 编辑:程序博客网 时间:2024/05/29 18:29
- public class StringDemo{
- public static void main(String[] args){
- testPoints("I love my job.");//一个参数传入
- testPoints("you","and","me");//3个String参数传入
- testPoints(new String[]{"you","and","me"});//可以看到传入三个String参数和传入一个长度为3的数组结果一样,再看例子
- System.out.println("---------------------------------------------------------");
- testPoints(7);
- testPoints(7,9,11);
- testPoints(new Integer[]{7,9,11});
- }
- public static void testPoints(String... s){
- if(s.length==0){
- System.out.println("没有参数传入!");
- }else if(s.length==1){
- System.out.println("1个参数传入!");
- }else{
- System.out.println("the input string is-->");
- for(int i=0;i<s.length;i++){
- System.out.println("第"+(i+1)+"个参数是"+s[i]+";");
- }
- System.out.println();
- }
- }
- public static void testPoints(Integer... itgr){
- if(itgr.length==0){
- System.out.println("没有Integer参数传入!");
- }else if(itgr.length==1){
- System.out.println("1个Integer参数传入!");
- }else{
- System.out.println("the input string is-->");
- for(int i=0;i<itgr.length;i++){
- System.out.println("第"+(i+1)+"个Integer参数是"+itgr[i]+";");
- }
- System.out.println();
- }
- }
- }
- --------------------------------------------------------
- 输出:
- 1个参数传入!
- the input string is-->
- 第1个参数是you;
- 第2个参数是and;
- 第3个参数是me;
- the input string is-->
- 第1个参数是you;
- 第2个参数是and;
- 第3个参数是me;
- ---------------------------------------------------------
- 1个Integer参数传入!
- the input string is-->
- 第1个Integer参数是7;
- 第2个Integer参数是9;
- 第3个Integer参数是11;
- the input string is-->
- 第1个Integer参数是7;
- 第2个Integer参数是9;
- 第3个Integer参数是11;
0 0
- java 传参数时 类型后跟 3个点 “...” 的意义
- java 传参数时 类型后跟 3个点 “...” 的意义
- java 传参数时 类型后跟 3个点 "..." 的意义
- Java类型后面的3个点的含义
- JAVA类型后面跟3个点(可变长度参数列表)
- JAVA类型后面跟3个点(可变长度参数列表)
- Egret)fps个参数的意义
- Listen第二个参数的意义
- Listen第二个参数的意义
- listen第二个参数的意义
- kmalloc第二个参数的意义
- Listen第二个参数的意义
- Listen第二个参数的意义
- like 后跟参数通配符
- java函数参数类型后添加三点的用法
- java函数参数类型后添加三点的用法
- java函数参数类型后添加三点的用法
- java函数参数类型后添加三点的用法
- read 与 fread 的区别的误解
- LLC算法coding与pooling解析
- SDK编程笔记 — 计时器篇两个计时器API的讨论
- ubuntu安装光盘修复grub-rescue引导失败问题
- Java web项目中读取配置文件
- java 传参数时 类型后跟 3个点 “...” 的意义
- C/C++中volatile关键字详解
- 用myeclipse从数据库生成hibernate的entity类
- 博客第一帖
- C++多线程编程
- 兼容不同版本的OpenCV头文件
- android.os.NetworkOnMainThreadException异常
- 内部类
- 类集框架