private List list(int... ints) {
List result = new ArrayList();
for (int i : ints) {
result.add(i);
}
return result;
}
I got this method from one of my friends and wondered what it does?
I have never seen int... ints construct before but am assuming it is an array of int and uses a for each construct to add each int in the array to result and return that List. Could someone pleas explain to me what the int... ints parameters mean, what they are doing, how to do that with other types, and if there are any advantages over int[] (if the paramter is just an array of int like I am guessing)?