Here's what I am trying to do:
public void add(Integer... newIntegers) {
for (Integer i : newIntegers) {
integers.add(i);
}
}
I am not sure why, but I can't put an ArrayList<Integer>
into the method.
I am more than happy to just copy the method for Lists but I thought that there had to be a more efficient way.
I tried the following thinking that I could do what you can do for a catch block:
public void add(Integer... | List<Integer> newIntegers) {
for (Integer i : newIntegers) {
integers.add(i);
}
}
However, after a quick StackOverfow, found it was impossible. Is there any other way?
List.of(E...)
and then call theadd(List<Integer>)
implementation.