java 传参数时 类型后跟 3个点 "..." 的意义
来源:互联网 发布:金融同业入门书 知乎 编辑:程序博客网 时间:2024/05/23 11:47
1、直接看代码就知道什么含义了!
- 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函数参数类型后添加三点的用法
- rem使用的js代码
- 新书《AngularJS半知半解》预热!
- iOS程序开发引用的第三方库之间出现冲突的处理方法
- 主键、外键,主表、从表
- PCIe总线学习笔记(一、PCI基础知识简介)
- java 传参数时 类型后跟 3个点 "..." 的意义
- 欧拉函数
- IMS消息
- 装虚拟机时vmware 报错an error has occurred. - no valid devices were found
- Ubuntu 12.04 搭建TFTP服务 亲测好用
- JAVA类加载和反射介绍
- JavaScript定时器详解
- c c++ "undefined reference to" 问题解决方法
- centos快捷安装PHP