public void testSubListAndNonStructuralChanges(){
  CopyOnWriteArrayList<String> list=new CopyOnWriteArrayList<String>();
  list.addAll(Arrays.asList("a","b","c","d","e"));
  List<String> bcd=list.subList(1,4);
  list.set(2,"C");
  try {
    bcd.get(1);
    fail();
  }
 catch (  ConcurrentModificationException expected) {
  }
}

public void testSubListAndNonStructuralChanges ( ) { CopyOnWriteArrayList < String > list = new CopyOnWriteArrayList < String > ( ) ; list . addAll ( Arrays . asList ( "a" , "b" , "c" , "d" , "e" ) ) ; List < String > bcd = list . subList ( 1 , 4 ) ; list . set ( 2 , "C" ) ; try { bcd . get ( 1 ) ; fail ( ) ; } catch ( ConcurrentModificationException expected ) { } }
the sub list throws on non - structural changes , even though that disagrees with the sublist ( ) documentation which suggests that only size - changing operations will trigger concurrentmodificationexception .
