title: Java: Comparing two created cards from a deck
body: <p>So I have a card class, deck class, and a game class. I have everything situated, except that I'm trying to compare a random card the computer generates, to a card that the player picks.</p>
  
  <p>Here is my String array of cards:</p>
  
  <pre><code>String[] suits = {"Spades", "Hearts", "Diamonds", "Clubs"};
  String[] ranks = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10",
                              "Jack", "Queen", "King"};
  </code></pre>
  
  <p>And here is my compareTo method, that I've implemented from Comparable to compare the generated card to the card the player has chosen, and return the higher of the two:</p>
  
  <pre><code>    public int compareTo(Card crd)
  {
      Card card1;
      int card1Suit = (int) (Math.random() * 4);
      int card1Rank = (int) (Math.random() * 13);
      card1 = new Card(a,b);
      if(card1.getRank().charAt(0) &lt; crd.getRank().charAt(0))
      {
          return 0;
      }
  
      return 1;
  }
  </code></pre>
  
  <p>I understand that just comparing the first character of the String array element isn't correct, but I don't know what to use to get the correct comparison to return the higher card. Any suggestions?</p>