Java,参数中的3个点以下方法中的三个点是什么意思?public void myMethod(String... strings){
// method body}
3 回答
慕工程0101907
TA贡献1887条经验 获得超5个赞
String
myMethod("foo", "bar");myMethod("foo", "bar", "baz");myMethod(new String[]{"foo", "var", "baz"}); // you can even pass an arrayString
public void myMethod(String... strings){
for(String whatever : strings){
// do what ever you want
}
// the code above is is equivalent to
for( int i = 0; i < strings.length; i++){
// classical for. In this case you use strings[i]
}}添加回答
举报
0/150
提交
取消
