title: Remove every 3rd element in arraylist
body: <p>I am trying to loop through an arraylist and gradually remove an element every 3 indices. Once it gets to the end of the arraylist I want to reset the index back to the beginning, and then loop through the arraylist again, again removing an element every 3 indices until there is only one element left in the arraylist. </p>
  
  <p>The listOfWords is an array with a length of 3 that was previously filled.</p>
  
  <pre><code>int listIndex = 0;
  
  do
  {           
      // just to display contents of arraylist    
      System.out.println(listOfPlayers);
  
      for(int wordIndex = 0; wordIndex &lt; listOfWords.length; wordIndex++
      {
          System.out.print("Player");
          System.out.print(listOfPlayers.get(wordIndex));
          System.out.println("");
          listIndex = wordIndex;                                  
      }           
  
      listOfPlayers.remove(listOfPlayers.get(listIndex)); 
  }
  while(listOfPlayers.size() &gt; 1);
  </code></pre>
  
  <p>I have tried to implement for several hours yet I am still having trouble. Here's what happens to the elements of the arraylist:</p>
  
  <pre><code>1, 2, 3, 4
  
  1, 2, 4
  
  1, 2
  </code></pre>
  
  <p>Then it throws an 'index out of bounds error' exception when it checks for the third element (which no longer exists). Once it reaches the last element I want it to wrap around to the first element and continue through the array. I also want it to start where it left off and not from the beginning once it removes an element from the arraylist. </p>