title: Java List and recursion leads to Concurrent Modification Exception
body: <p>The following function walks recursively through a list and divide it always by half and do something with the sublists. The recursion breaks when the listsize is 2. I know a concurrent modification exception occurs if I change the list when I iterate over it. But I don't use iterations and it still happens: </p>
  
  <pre><code>    private static List&lt;ParticipantSlot&gt; divide(List&lt;ParticipantSlot&gt; list) {
          int n = list.size();
  
          //do something 
  
          if (n&gt;2){
              List&lt;ParticipantSlot&gt; l = divide(list.subList(0, n/2-1));
              List&lt;ParticipantSlot&gt; r= divide(list.subList(n/2, n));
  
              l.addAll(r);
              return l;
          }else{
              return list;
          }
      }
  </code></pre>