Sunday, February 3, 2013

Java List Remove Method is Optional

http://docs.oracle.com/javase/7/docs/api/java/util/List.html#remove(int)
Removes the element at the specified position in this list (optional operation)

http://stackoverflow.com/questions/4243786/how-to-remove-element-from-java-util-list
The top answer to this question provides an interesting solution:

public void removeImage(int index) { 
    if (images != null) {
         try { 
            images.remove(index); 
         } catch (UnsupportedOperationException uoe) { 
            images = new ArrayList(images); 
            images.remove(index); 
         }
    }
}