By Chris on October 12, 2014
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));
Posted in java, prog | Tagged arraylist, java, java.util.List |
By Chris on September 5, 2013
They’re always a question that comeback either in interview or when you are playing old code. Why the hell are they using Vector over arrayList ? Vector is a class that exists since the beginning of java (aka Java 1.0) it’s implement List. It seems to pollute old code and still use programmer that don’t […]
Posted in prog, tips | Tagged arraylist, collections, java, java.util.List, List, synchronization, synchronizedList, vector |
Recent Comments