Java Community | Help. Code. Learn.JC|HCL
Java Community | Help. Code. Learn.โ€ข4y agoโ€ข
18 replies
Pleezon

4 lines of mayhem

    public static void main(String[] args)
    {
        List<Integer> list = new ArrayList<>();
        List<Integer> subList = list.subList(0, 0);
        list.addAll(subList);
        list.addAll(subList);
    }

Throws a ConcurrentModificationException in the last line, and I have no clue why.
Was this page helpful?