Considerations when using variable parameters

Variable parameters are new features that appeared after JDK 1.5.

Prerequisites: When the data type of the parameter list of the method has been determined, but the number of parameters is uncertain, variable parameters can be used.

The principle of variable parameters: The bottom layer of variable parameters is an array. Depending on the parameters passed, different length arrays will be created to store these parameters.

Note that the parameter list of a method can only have one variable parameter. If the method has multiple parameters, the variable parameter must be written at the end of the parameter list.

Published 94 original articles · liked 0 · visits 722

Guess you like

Origin blog.csdn.net/qq_46578181/article/details/105283558