private void Removetempfiles (String ... fileNames) {for
(string filename:filenames) {
try {
new File (Filena Me). Delete ();
} catch (Exception e) {
}
}
}
Where the String ... fileNames means.
Three dots after the type (String ...)., starting with Java 5, the Java language supports a new approach to method parameters, called variable-length argument lists, whose syntax is the type heel ..., which means that the parameters accepted here are 0 to more objects of type object, or a object[]. For example, we have a method called Test (string...strings), so you can also write method test (), but you can't write test (string[] strings), which will cause a compile error, and the system prompts for a duplicate.
In use, for Test (string...strings), you can use test () directly to invoke, marked without parameters, can also be used to test ("AAA"), can also use test (new string[]{"AAA", "BBB"}).
Also, if you have both the test (string...strings) function and the test () function, we will use the test () function preferentially when we call Test (). Only if the test () function is not available, we call Test () and the program goes to test (string...strings).
Example one:
public class Ttest {
//private static int A;
public static void Test (int ... a) {for
(int i=0;i<a.length;i++) {
System.out.println (a[i]);
}
public static void Main (string[] args) {
ttest.test (1,2);
}
Case TWO:
String ... excludeproperty represents an indefinite parameter, which means that you can pass in multiple string objects when you invoke this method.
public static void Main (string[] args) {
//test, passing in multiple parameters
test ("Hello", "World", "13SD", "Country", "Cum", "ICT"); c12/>} public
static void Test (String ... arguments) {for
(int i = 0; i < arguments.length; i++) {
syste M.out.println (Arguments[i]);