One, the use of indefinite parameter list:
void f (String ... strs); // here the parameter type is string, the number of arguments is unknown, "," delimited append & This parameter can be dynamically generated an array based on the number of arguments, and then passed into the method execution
Two, the indefinite parameter has two stipulation
1, the parameter list of the method has only one parameter of indefinite length;
2. The position of an array of indefinite length must be the last parameter, or it cannot be compiled.
When this method is actually called, the JVM will not know how long the previous indefinite length parameter is, and where the next parameter starts
Third, code example
/*** Function: Whether multiple parameters are not NULL, "", "" .<br/> * date:2017 June 20 pm 4:03:01 <br/> * *@author[email protected] *@paramparams *@return */ Public StaticBoolean Notblank (String ... params) {if(NULL= = Params | | Params.length = = 0) {//the number of params is treated as an array return false; } for(String param:params) {if(Stringutils.isblank (param)) {return false; } } return true; }
Java mutable parameter list