I am not sure of the vocabulary I am using here, please correct me if I\'m wrong.
In Javascript, I had the following code:
let args = [1,2,3];
func
In java there is concept of Variable Arguments, using which you can pass different numbers of arguments to same function.
I am taking your code as an example :
public class Foo {
public int doSomething (int ...a) {
int sum = 0;
for (int i : a)
sum += i;
return sum;
}
}
Now you can call this function as :
doSomething (args)
For more information you can visit below link : http://www.geeksforgeeks.org/variable-arguments-varargs-in-java/