java.util.Arrays.asList when used with removeIf throws UnsupportedOperationException

java.util.Arrays.asList() produces a list from which it is impossible to remove elements, so it throws on a removal attempt.

You could wrap it with ArrayList:

List<Integer> ints = new java.util.ArrayList<>(java.util.Arrays.asList(1,20,20));

Update

Arrays.asList() returns return new ArrayList<>(a); where ArrayList is not java.util.ArrayList, but java.util.Arrays.ArrayList (internal class), which does not allow removal.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)