Today, I saw a list of function parameters test (int...,
The original usage is as follows:
The following three vertices of the type (String...) Start from Java 5. the Java language supports a new method for method parameters,
It is called the variable length parameter list. Its syntax is the type followed by..., indicating that the parameters accepted here are 0 to multiple objects.
Type Object, or an Object []. For example, we have a method named test (String... strings ),
You can also write the test () method, but you cannot write test (String [] strings). This will cause a compilation error,
The system prompts a duplicate method.
When using test (String... strings), you can use test () to call it directly, indicating that no
You can also use test ("aaa") or test (new String [] {"aaa", "bbb "}).
In addition, if both the test (String... strings) function and the test () function exist, when we call test,
The test () function is used first. Only when we call test () without the test () function will the program go through
Test (String... strings ).
Example:
Public class Ttest {// private static int a; public static void test (int... a) {for (int I = 0; I <. length; I ++) {System. out. println (a [I]) ;}} public static void main (String [] args) {Ttest. test (1, 2 );}}
Source: http://hi.baidu.com/8741659422/blog/item/a1f3384c2035a3edd72afc3e.html