While trying to remove a element after creating a List from a array using the Array.asList(array[]) method I’ve stumbled on that error.
java.lang.UnsupportedOperationException at java.util.AbstractList.add(AbstractList.java:131) at java.util.AbstractList.add(AbstractList.java:91)
Then I remember this, list created by the Arrays.asList
method are immutable
Same goes for empty lists. So instead create a arraylist :
List<String> list = new ArrayList<String>(Arrays.asList(split));
Recent Comments