What do 3 dots next to a parameter type mean in Java?

前端 未结 12 1694
灰色年华
灰色年华 2020-11-22 00:27

What do the 3 dots following String in the following method mean?

public void myMethod(String... strings){
    // method body
}
12条回答
  •  灰色年华
    2020-11-22 00:34

    String... is the same as String[]

    import java.lang.*;
    
    public class MyClassTest {
    
        //public static void main(String... args) { 
    
        public static void main(String[] args) {
            for(String str: args) {
                System.out.println(str);
            }
        }
    }
    

提交回复
热议问题