variable parameters have been introduced from Java5, which is the extension of Java methods and Arrays!
The parameters that can be accepted in a method are no longer a fixed number, but are determined by how much specific requirements are passed.
define the format: return value type Method Name ( parameter type ... formal parameters ) {}
features of variable parameters:
Can only appear at the end of the parameter list;
... Between the variable type and the variable name, there are no spaces before and after it can be ;
When you call a method of a mutable parameter, the compiler creates an array for the mutable parameter implicitly, accessing the mutable parameter as an array in the method body.
PackageReviewdemo;Importjava.util.Arrays; Public classDemo6 { Public Static voidMain (string[] args) {int[]age = {1,2,3,69,36,636,459}; Show (age); } Public Static voidShowint.. a) {//This is what is written here is the variable parameter, and the function of the array! //print out the array! System.out.println (Arrays.tostring (a)); }}
Variable parameters in Java