### Question:
Iterators { public static int failFast2() { ArrayList<Integer> numbers = new ArrayList<>(); numbers.add(10); numbers.add(20); numbers.add(30); numbers.add(40); Iterator<Integer> iterator = numbers.iterator(); while (iterator.hasNext()) { if (iterator.next() == 30) { iterator.remove(); } } System.out.println("using iterator's remove method = " + numbers); iterator = numbers.iterator(); while (iterator.hasNext()) { if (iterator.next() == 40) { numbers.remove(2); } } return numbers.size(); }  static int failFast1(); static int failFast2(); static int failSafe1();  }### Answer:
@Test public void whenFailFast_ThenThrowsExceptionInSecondIteration() { assertThatThrownBy(() -> { failFast2(); }).isInstanceOf(ConcurrentModificationException.class); }