What is a java mutable parameter
A mutable parameter is a feature introduced in Java 1.5 that allows a method to accept any number of arguments.
Package Simplejava; Public class Q25 { publicstaticvoid print (String ... s) { for (String a:s) System.out.println (a); } Public Static void Main (string[] args) { print ("a"); Print ("A", "B"); Print ("A", "B", "C");} }
How a variable parameter works
When a variable parameter is used, an array is created, its array length is the number of arguments, then the parameters are passed to the array, and the array is passed to the method.
When to use variable parameters
As its name, the variadic mechanism is useful when a method needs to handle any number of arguments; A good example is the String.Format (String format, Object ... args) method in the JDK, The method can receive any number of parameters for string formatting, so it can be implemented using a variable-parameter mechanism.
Link: http://www.programcreek.com/2014/01/java-varargs-examples/
Example of java variable parameter "simple Java"