June 2018
Beginner
722 pages
18h 47m
English
The separator ... (ellipsis) is used only for varargs:
int someMethod(int i, String s, int... k){ //k is an array with elements k[0], k[1], ...}
The preceding method can be called in any of the following ways:
someMethod(42, "abc"); //array k = nullsomeMethod(42, "abc", 42, 43); //k[0] = 42, k[1] = 43int[] k = new int[2];k[0] = 42;k[1] = 43;someMethod(42, "abc", k); //k[0] = 42, k[1] = 43
In Chapter 2, Java Language Basics, while talking about the main() method, we explained the concept of varargs (variable arguments) in Java.
Read now
Unlock full access