(String[] args)
| 7 | |
| 8 | public class FailFast { |
| 9 | public static void main(String[] args) { |
| 10 | Collection<String> c = new ArrayList<>(); |
| 11 | Iterator<String> it = c.iterator(); |
| 12 | c.add("An object"); |
| 13 | try { |
| 14 | String s = it.next(); |
| 15 | } catch(ConcurrentModificationException e) { |
| 16 | System.out.println(e); |
| 17 | } |
| 18 | } |
| 19 | } |
| 20 | /* Output: |
| 21 | java.util.ConcurrentModificationException |