title: removing one item from an array at a time
body: <p>I've seen some similar questions, but none seem to address the issue I'm having.</p>
  <p>I believe the issue lies here:</p>
  <pre><code>    public static void dealCard(Card[] deck){
  
      System.out.println(deck[0]);
      Card [] decks = new Card[deck.length-1];
  
      for (int x = 0; x&lt;deck.length-1; x++)
      decks[x] = deck[x];
      deck = decks;
  
  }
  </code></pre>
  <p>So effectively what I'm trying to do every time I call this method is to print the first object in the array, and then subtract the first object from the array. Of course, neither of which are happening, because I don't know what the hell I'm doing.</p>
  <p>Complete code:</p>
  <pre><code>import java.util.Random;
  public class Main {
  private Card [] deck;
  
  
      public static void printDeck(Card[] deck){
          for (Card d : deck)
          System.out.println(&quot;  &quot; + d);
      }
  
      public static void shuffle(Card[] deck){ //  shuffles deck
          int index;
  
          Random ran = new Random();
  
          for (int i = deck.length -1; i &gt; 0; i--){
          int poker = ran.nextInt(i + 1);
          Card b = deck[poker];
          deck[poker] = deck[i];
          deck[i] = b;
  
          }
      }
      public static void dealDeck(Card[] deck){
  
           for (Card a : deck)
           System.out.println(&quot;  &quot; + a);
      }
  
      public static void dealCard(Card[] deck){
  
          System.out.println(deck[0]);
          Card [] decks = new Card[deck.length-1];
  
          for (int x = 0; x&lt;deck.length-1; x++)
          decks[x] = deck[x];
          deck = decks;
  
      }
  
  
  
  
      public static void main(String[] args) {
  
          Card card0 = new Card();
          Card card1 = new Card();
          Card card2 = new Card();
          Card card3 = new Card();
          Card card4 = new Card();
          Card card5 = new Card();
          Card card6 = new Card();
          Card card7 = new Card();
          Card card8 = new Card();
          Card card9 = new Card();
          Card card10 = new Card();
          Card card11 = new Card();
          Card card12 = new Card();
          Card card13 = new Card();
          Card card14 = new Card();
          Card card15 = new Card();
          Card card16 = new Card();
          Card card17 = new Card();
          Card card18 = new Card();
          Card card19 = new Card();
          Card card20 = new Card();
          Card card21 = new Card();
          Card card22 = new Card();
          Card card23 = new Card();
          Card card24 = new Card();
          Card card25 = new Card();
          Card card26 = new Card();
          Card card27 = new Card();
          Card card28 = new Card();
          Card card29 = new Card();
          Card card30 = new Card();
          Card card31 = new Card();
          Card card32 = new Card();
          Card card33 = new Card();
          Card card34 = new Card();
          Card card35 = new Card();
          Card card36 = new Card();
          Card card37 = new Card();
          Card card38 = new Card();
          Card card39 = new Card();
          Card card40 = new Card();
          Card card41 = new Card();
          Card card42 = new Card();
          Card card43 = new Card();
          Card card44 = new Card();
          Card card45 = new Card();
          Card card46 = new Card();
          Card card47 = new Card();
          Card card48 = new Card();
          Card card49 = new Card();
          Card card50 = new Card();
          Card card51 = new Card();
  
          card0.setCard(1, 1);
          card1.setCard(2, 1);
          card2.setCard(3, 1);
          card3.setCard(4, 1);
          card4.setCard(5, 1);
          card5.setCard(6, 1);
          card6.setCard(7, 1);
          card7.setCard(8, 1);
          card8.setCard(9, 1);
          card9.setCard(10, 1);
          card10.setCard(11, 1);
          card11.setCard(12, 1);
          card12.setCard(13, 1);
          card13.setCard(1, 2);
          card14.setCard(2, 2);
          card15.setCard(3, 2);
          card16.setCard(4, 2);
          card17.setCard(5, 2);
          card18.setCard(6, 2);
          card19.setCard(7, 2);
          card20.setCard(8, 2);
          card21.setCard(9, 2);
          card22.setCard(10, 2);
          card23.setCard(11, 2);
          card24.setCard(12, 2);
          card25.setCard(13, 2);
          card26.setCard(1, 3);
          card27.setCard(2, 3);
          card28.setCard(3, 3);
          card29.setCard(4, 3);
          card30.setCard(5, 3);
          card31.setCard(6, 3);
          card32.setCard(7, 3);
          card33.setCard(8, 3);
          card34.setCard(9, 3);
          card35.setCard(10, 3);
          card36.setCard(11, 3);
          card37.setCard(12, 3);
          card38.setCard(13, 3);
          card39.setCard(1, 4);
          card40.setCard(2, 4);
          card41.setCard(3, 4);
          card42.setCard(4, 4);
          card43.setCard(5, 4);
          card44.setCard(6, 4);
          card45.setCard(7, 4);
          card46.setCard(8, 4);
          card47.setCard(9, 4);
          card48.setCard(10, 4);
          card49.setCard(11, 4);
          card50.setCard(12, 4);
          card51.setCard(13, 4);
  
  
  
          Card [] deck = {card0, card1, card2, card3, card4, card5, card6, card7, card8, card9, card10, card11, card12, card13,
                  card14, card15, card16, card17, card18, card19, card20, card21, card22, card23, card24, card25, card26, card27, card28,
                  card29, card30, card31, card32, card33, card34, card35, card36, card37, card38, card39, card40, card41, card42, card43,
                  card44, card45, card46, card47, card48, card49, card50, card51,
                  };
  
          System.out.println(&quot;The deck before being shuffled:&quot;);
          printDeck(deck);
          System.out.println(&quot;\n The deck has now been shuffled: \n&quot;);
          shuffle(deck);
          dealDeck(deck);
          System.out.println(&quot;deals a card:&quot;);
          dealCard(deck);
          dealCard(deck);
          dealCard(deck);
          dealCard(deck);
  
  
  }
  }
  </code></pre>
  <p>So I tried this:</p>
  <pre><code>System.out.println(deck[0]);
          Card [] decks = new Card[deck.length-1];
          int j = 0;
  
          for (int x = 1; x&lt;deck.length-1; x++){
  
          decks[j] = deck[x];
          j++;
          
          }
          deck = decks;
  </code></pre>
  <p>and it still produces the same object with the prinln, if I put the println anywhere in this method the same object is printed over and over again.</p>
  <p>Here is the Card class:</p>
  <pre><code>import java.util.Random;
  public class Card {
  
     int face = 0;
          int suit = 0;
          String faceText;
          String faceValue;
          String suitValue;
          String suitText;
  
          public Card() // card constructor, initially generates card number and suit
          {
              int face = 0;
              int suit = 0;
              Random generator = new Random();
              face = generator.nextInt(13) + 1;
              suit = generator.nextInt(4) + 1;
  
  
          }
  
          public int getFace() // sets up card face value
          {
              Random generator = new Random();
              face = generator.nextInt(13) + 1;
              return face;
          }
  
          public int getSuit() // sets up card suit value
          {
              Random generator = new Random();
              suit = generator.nextInt(4) + 1;
              return suit;
          }
          public String getFacetext() // gets card numeric value textually
          {
              switch(face)
              {
                  case 1:
                      faceText = &quot;one&quot;;
                      break;
  
                  case 2:
                      faceText = &quot;two&quot;;
                      break;
  
                  case 3:
                      faceText = &quot;three&quot;;
                      break;
  
                  case 4:
                      faceText = &quot;four&quot;;
                      break;
  
                  case 5:
                      faceText = &quot;five&quot;;
                      break;
  
                  case 6:
                      faceText = &quot;six&quot;;
                      break;
  
                  case 7:
                      faceText = &quot;seven&quot;;
                      break;
  
                  case 8:
                      faceText = &quot;eight&quot;;
                      break;
  
                  case 9:
                      faceText = &quot;nine&quot;;
                      break;
  
                  case 10:
                      faceText = &quot;ten&quot;;
                      break;
  
                  case 11:
                      faceText = &quot;eleven&quot;;
                      break;
  
                  case 12:
                      faceText = &quot;twelve&quot;;
                      break;
  
                  case 13:
                      faceText = &quot;thirteen&quot;;
                      break;
              }
  
              return faceText;
          }
  
          public String getSuittext() // gets card's suit value
          {
              switch (suit)
              {   case 1:
                  suitText = &quot;hearts &quot;;
                  break;
  
                  case 2:
                      suitText = &quot;spades &quot;;
                      break;
  
                  case 3:
                      suitText = &quot;diamonds &quot;;
                      break;
  
                  case 4:
                      suitText = &quot;clubs &quot;;
                      break;
  
              }
              return suitText;
          }
          public String setCard(int face, int suit) // sets the card to passed through toString
          {
              switch (face)
              {
                  case 1:
                      faceValue = &quot;ace&quot;;
                      break;
  
                  case 2:
                      faceValue = &quot;two&quot;;
                      break;
  
                  case 3:
                      faceValue = &quot;three&quot;;
                      break;
  
                  case 4:
                      faceValue = &quot;four&quot;;
                      break;
  
                  case 5:
                      faceValue = &quot;five&quot;;
                      break;
  
                  case 6:
                      faceValue = &quot;six&quot;;
                      break;
  
                  case 7:
                      faceValue = &quot;seven&quot;;
                      break;
  
                  case 8:
                      faceValue = &quot;eight&quot;;
                      break;
  
                  case 9:
                      faceValue = &quot;nine&quot;;
                      break;
  
                  case 10:
                      faceValue = &quot;ten&quot;;
                      break;
  
                  case 11:
                      faceValue = &quot;jack&quot;;
                      break;
  
                  case 12:
                      faceValue = &quot;queen&quot;;
                      break;
  
                  case 13:
                      faceValue = &quot;king&quot;;
                      break;
              }
  
              switch (suit)
              {
                  case 1:
                      suitValue = &quot;hearts &quot;;
                      break;
  
                  case 2:
                      suitValue = &quot;spades &quot;;
                      break;
  
                  case 3:
                      suitValue = &quot;diamonds &quot;;
                      break;
  
                  case 4:
                      suitValue = &quot;clubs &quot;;
                      break;
              }
  
              return suitValue;
          }
  
          public String toString()
          {
              String result = faceValue + &quot; of &quot; + suitValue;
              return result;
          }
  
  
  }
  </code></pre>