Code example for CopyOnWriteArrayList

Methods: subList

0
        bcd.addAll(Arrays.asList("B", "C", "D"));
        assertEquals(Arrays.asList("a", "B", "C", "D", "e"), list);
    } 
 
    public void testSubListClearWhenEmpty() { 
        new CopyOnWriteArrayList<String>().subList(0, 0).clear(); // the RI fails here
    } 
 
    public void testSubListIteratorGetsSnapshot() { 
        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<String>();
        list.addAll(Arrays.asList("a", "b", "c", "d", "e"));
        Iterator<String> bcd = list.subList(1, 4).iterator();
        list.clear();
        assertEquals("b", bcd.next());
        assertEquals("c", bcd.next());
        assertEquals("d", bcd.next());
        assertFalse(bcd.hasNext());
    } 
 
    public void testSubListRemoveByValue() { 
        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<String>();