Exception in thread "main" java.lang.UnsupportedOperationException at java.util.AbstractList.add(AbstractList.java:131) at java.util.AbstractList.add(AbstractList.java:91) at TestAsList.main(TestAsList.java:12)
The java docs for Arrays.asList say that "Returns a fixed-size list backed by the specified array." If you want a modifiable list you can do something like "ArrayList anotherList = new ArrayList(aList)".
Ping & DNS - updated with new look and Ping home screen widget
Joined: Jul 12, 2007
Thanks it works...
However I do still have the same doubt, as per the documentation
Returns a fixed-size list backed by the specified array. (Changes to the returned list "write through" to the array.)
Does this mean we cannot change the list..then how will it change the array as per the line "(Changes to the returned list "write through" to the array.)"