Problem is that Arrays.asList
method returns instance of java.util.Arrays.ArrayList which doesn't support add/remove operations on elements. It's not surprizing that addAll
method throws exception because add method for java.util.Arrays.ArrayList
is defined as:
public void add(int index, E element) {
throw new UnsupportedOperationException();
}
Related question:
Arrays.asList() Confusing source code
From the documentation:
Arrays.asList returns a fixed-size list backed by the specified array.