title: In some Java code, why does the class Deck extend the Card class?
body: <p>I am reading some code in Java, which I am not familiar with, but it seems weird that if a class is <code>Deck</code> (for a deck of cards), it already has an instance variable of an array of <code>Cards</code>, so why does <code>Deck</code> extend or inherit <code>Card</code>?  I thought class A inherits class B only if A is a B (Cat inherits Animal because a cat is an animal).</p>
  
  <p>The code is below:</p>
  
  <pre><code>public class Deck &lt;T extends Card&gt; {
      private ArrayList&lt;T&gt; cards;
      private int dealtIndex = 0; // marks first undealt card
  
      public Deck() {
      }
  
      public void setDeckOfCards(ArrayList&lt;T&gt; deckOfCards) {
          cards = deckOfCards;
      }
  
      public void shuffle() {
          for (int i = 0; i &lt; cards.size(); i++) {
  
      [...]
  }
  
  public abstract class Card {
      private boolean available = true;
  
      /* number or face that's on card - a number 2 through 10, 
       * or 11 for Jack, 12 for Queen, 13 for King, or 1 for Ace 
       */
      protected int faceValue;
      protected Suit suit;
  
      public Card(int c, Suit s) {
          faceValue = c;
          suit = s;
      }
  
      public abstract int value();
  
      public Suit suit() { 
          return suit; 
      }
  
      [...]
  
  }
  </code></pre>