String ... <varname> whats String ... means
I am trying to figure out some kind of Java code. I came across something that I had not seen in the method header before
private static object [] methodName(NodeList nodes, String... Names) What is an operator ... ?
Thank you and sorry, some searches did not find it elsewhere
+6
Peter
source share2 answers
This is a varargs ad.
This suggests that you can call this method with 0 or more String arguments as final arguments. Instead:
write(new String[]{"A","B","C"}); you can use
write("A", "B", "C"); So each line is a different argument. Then you can iterate over them, for example.
public void write(String... records) { for (String record: records) System.out.println(record); } Additional examples here .
+8
Brian agnew
source share... stands for "varargs", meaning you can provide an arbitrary number of String arguments. See http://download.oracle.com/javase/1.5.0/docs/guide/language/varargs.html .
+2
Oliver Charlesworth
source share