I recently found that the code in a project has the following usage
public static void checkResponseStatus(HttpResponse.RespModel response, boolean success, String...msg) {
String template = "xxxx";
Assert.assertEquals(!response.isHasError(), success, realMsg);
}
One of the input parameters is String...msg.
After consulting, this is a new way of writing in Java.
…Is a new way of writing method parameters supported by the Java language, called variable-length parameter list. The syntax is type followed by …, which means that the parameters accepted here are 0 or more objects of type Object, or an Object[].
The test code is as follows:
public class main {
public static void main(String[] args) {
myTest("aaa","bbb");
myTest("aaa","bbb","ccc","ddd");
}
public static void myTest(String str1 ,String... strs){
for(String str : strs){
System.out.println(str);
}
System.out.println(str1);
}
}
The console output is as follows: