当前位置:网站首页>String... 可变长度参数列表
String... 可变长度参数列表
2022-07-21 14:59:00 【预立科技】
一次看到String…时,这是什么语法,查找资料后,原来它叫可变长度参数列表
String…
1.参数类型是String;
2.参数个数有0个,或多个; String…可以类比成数组String[],数组长度不定(长度可以是0,也可以大于0)
public class DemoController {
public void test(String aa){
run();
run("a");
run("a","b");
run("a","b","c");
/* run("a","b","c",.......); */
run(new String[]{
"a","b","c","d","e"});
}
/*public void run(){ }*/
public void run(String... strings){
for (String item:strings) {
String s = item;
}
}
}
当调用run()时,优先调用无参的方法run(), 当不存在无参的方法run(),再调用run(String… strings)
边栏推荐
猜你喜欢
rider 切换主题
Keithley software 2600 series 2635b | 2636b | 2651a | 2657a ns SourceMeter source table software
OS实验五 基于内核栈切换的进程切换
U++ 学习笔记 悬浮Actor
IP地址分类及范围
NI LABVIEW 2019安装教程,ATECLOUD免安装可在线使用
吉时利Keithley软件2400|2401|2410|2420|2425|2430 NS-SourceMeter源表软件
Keithley software 2600 series 2601b | 2602b | 2604b | 2606b ns SourceMeter source table software
Software testing: equivalence testing, decision table based testing and comprehensive problem analysis
开发动态 | StoneDB 2022年版本发布里程碑
随机推荐
Detailed explanation of PLC cascade PID control (temperature control of furnace and central air conditioning system)
OSPF实验演示(Huawei路由器设备配置)
Programming Language Pragmatics 习题解答(一)
Qt之生成连接库
Buffer Overflow Vulnerability Lab实验记录
Shortcut keys for switching between the latest version of win10 and changing languages
ECCV 2022 Oral《Unicorn》首次统一了四项目标跟踪任务的网络结构与学习范式,在8个富有挑战性的数据集上SOTA...
rider 切换主题
射频线缆自动测试系统,让你的测试效率提高60倍
ApacheCon Asia 2022 开启报名:Pulsar 技术议题重磅亮相
U++ property ufunction Foundation
U++ learning notes floating actor
Leetcode skimming: balanced binary tree and flipped binary tree
懒癌福音!可替代LabVIEW的软件—ATECLOUD智能云测试平台
Keithley software 2600 series 2635b | 2636b | 2651a | 2657a ns SourceMeter source table software
吉时利Keithley软件2400|2401|2410|2420|2425|2430 NS-SourceMeter源表软件
课题六 - 消息队列实现客户机通信
携手HMS Core分析服务,以数据助力游戏高效增长
Determine the position of an element in an array, and move all subsequent values backward after insertion
启牛老师让开证券账户安全吗?可以开吗?