-2
public class Venus {
    public static void main(String[] args) {
        int [] x = {1,2,3};
        int y[] = {4,5,6};
        new Venus().go(x,y);
    }
    void go(int[]... z) { 
        /*
         *here where my doubt goes about how the "..." operator works
         */

    for(int[] a : z)
        System.out.print(a[0]);
}

}

output of this code snippet is "14"

aydinugur
  • 1,208
  • 2
  • 14
  • 21

1 Answers1

0

... is the elipsis (varargs) operator. In short, it's a syntactic sugar that allows you to pass a variable number of arguments to the method using commas (,). Inside the method, the argument is treated as an array.

So int[]... z means that z is treated as an array of int[], or int[][].

Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • 1
    If you think that this answer was helpful you might want to consider upvoting this answer to say "thank you" another way here at Stack Overlflow :-) – Przemysław Moskal Dec 17 '17 at 09:37