Only one variable parameter can be specified in a method, and it must be the last parameter of the method. Any ordinary arguments must be declared before it.
1.1 Variable parameter Format
Variable parameter format: typeName… ParameterName Example: String… Args variables are treated as arrays in methods.
1.2 Four modes of variable parameter Transmission
- Nothing is passed, the variable argument receives an array of length 0;
- pass
null
Value; - The array;
- One or more parameters;
1.3 Differences between mutable parameters and arrays
- In terms of the number of variables, there can only be one variable parameter, and there can be multiple arrays.
- Mutable arguments can only be defined at the end of the argument list, and arrays can be anywhere;
- Mutable arguments can be passed to arrays, NULL, zero arguments, one to more arguments, and arrays can be passed to array references, array objects, and NULL