title: Coding War and struggling with displaying cards played
body: <p>I'm working on coding War in Java.  It works, except I'm having trouble printing out the cards played.  Right now I have this:</p>
  <pre><code>    for (int i=0; i&lt;26; i++) {
          int p1Value = player1.flip().getRank();
          System.out.println(&quot;Player 1 plays the &quot; + player1.flip().toString());
          int p2Value = player2.flip().getRank();
          System.out.println(&quot;Player 2 plays the &quot; + player2.flip().toString());
          System.out.println(&quot;-------------------------------------&quot;);
          
          
  
          //compare card values &amp; allots point to the higher one
          if(p1Value &gt; p2Value) {
              player1.incrementScore();
              showMessageDialog(null, &quot;Player 1 wins the round.&quot;);//alerts w
          }
          
          else if (p2Value &gt; p1Value) {
              player2.incrementScore();
              showMessageDialog(null, &quot;Player 2 wins the round.&quot;);
          }
          else {
              showMessageDialog(null, &quot;It's a tie! No points awarded.&quot;);
          
          }
      }
          
  </code></pre>
  <p>Changing to this has caused it to it to run only 13 times instead of 26 (but works the 13 times).  Before I added the Sysouts, it worked fine 26 times, but just didn't print the cards played.  My best guess is that I'm using up a separate card each time I say that a player is flipping.  I tried to assign it to a variable hoping that would help, but it didn't.  Am I right?  How can I fix?  TIA</p>
  <p>Prints play(Player 1 plays the ___ and Player 2 plays the ___) 13 times.  Then this error:</p>
  <p>Exception in thread &quot;main&quot; java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0</p>
  <pre><code>at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
  
  at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
  
  at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
  
  at java.base/java.util.Objects.checkIndex(Objects.java:359)
  
  at java.base/java.util.ArrayList.remove(ArrayList.java:504)
  
  at Players.flip(Players.java:48)
  
  at War.main(War.java:32)
  </code></pre>