Im trying to figure out some java code. I came across something I have not seen before in a method header
private static object [] methodName(NodeList nodes, String... Names)
Whats is the operator ...
?
Thanks and sorry did some searches could not find it elsewhere
That's a varargs declaration.
It's saying that you can call that method with 0 or more String arguments as the final arguments. Instead of:
write(new String[]{"A","B","C"});
you can use
write("A", "B", "C");
So each string is a different argument. You can then iterate through them e.g.
public void write(String... records) {
for (String record: records)
System.out.println(record);
}
More examples here.
The ...
denotes "varargs", i.e. you can provide an arbitrary number of String
arguments. See http://download.oracle.com/javase/1.5.0/docs/guide/language/varargs.html.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With