Code example for CopyOnWriteArrayList

Methods: addAllclearsubList

0
        } catch (ConcurrentModificationException expected) {
        } 
    } 
 
    public void testSubListAndStructuralChanges() { 
        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<String>();
        list.addAll(Arrays.asList("a", "b", "c", "d", "e"));
        List<String> bcd = list.subList(1, 4);
        list.clear();
        try { 
            bcd.get(1);
            fail();
        } catch (ConcurrentModificationException expected) {
        } 
    } 
 
    public void testSubListAndSizePreservingStructuralChanges() { 
        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<String>();
        list.addAll(Arrays.asList("a", "b", "c", "d", "e"));
        List<String> bcd = list.subList(1, 4);
Connect your IDE to all the code out there  Get Codota for Java