title: Using next() to call next iteration of ArrayList
body: <p>Having a little bit of trouble with the iterator next(). Can't seem to get it to work properly. I've been working on this code for a while so I was thinking another set of eyes would help.</p>
  
  <p>This is my deck class with creates a list of Card objects, I'm trying to make a method to grab the next Card in the list starting with the first one:</p>
  
  <pre><code>package blackjack;
  
  import blackjack.Card.Rank;
  import blackjack.Card.Suit;
  import java.util.*;
  
  public class Deck {
  
  public ArrayList&lt;Card&gt; cards = new ArrayList&lt;&gt;();
  int i;
  Card next;
  
  public Deck() {
      initializeDeck();
  
  }
  
  public void printDeck() {
      for (Card c: cards)
          System.out.println(c);
  }
  
  private void initializeDeck() {
      for (Suit suit : Suit.values()) {
          for (Rank rank : Rank.values()) {
              cards.add(new Card(rank, suit));
          }
      }
  }
  
  public Card getNextCard() {
      if (cards.listIterator().hasNext() != true) {
          getNextCard();
      }
      else {
          next = cards.listIterator().next();
      }
        return next; 
  }
  }
  </code></pre>
  
  <p>This is my main class where I call the getNextCard() and what I'm thinking it should do is print the first and then the next Card in the list but what it's doing is printing the first Card twice.</p>
  
  <pre><code>package blackjack;
  
  import java.util.*;
  
  public class BlackJack {
  
  public static void main(String[] args) {
      Deck deck = new Deck();
      System.out.println(deck.getNextCard());
      System.out.println(deck.getNextCard());
      }
  
  }
  </code></pre>
  
  <p>Thanks in advance for any help!</p>