title: Why does the variable does not store the value in this java program?
body: <p>I get an error that the variable might not be initialized. Im using a normal String data type and an if..else statement for the decision.This is a program about giving out 5 random cards to the user.The error im getting is on in the first statement of the if else statement, i think the variable assignment method is correct, and even tried it in other programs and it works in those. Can someone find the bug in this?</p>
  
  <pre><code>import java.util.Random;
  public class RandomCard 
  {
  public static void main(String[] args)
  {
      int cardNumber;
      int cardSign;
      String sign;
      Random card = new Random();
      for(int counter = 0; counter &lt; 5; counter++)
      {
  
          cardSign = card.nextInt(4);
  
          if(cardSign == 0)
          {
              sign = "Spades";
          }
  
          else if(cardSign == 1)
          {
              sign = "Hearts";
          }
  
          else if(cardSign == 2)
          {
              sign = "Clubs";
          }
  
          else if(cardSign == 3)
          {
              sign = "Diamond";
          }
  
  
  
          cardNumber = 1 + card.nextInt(13);
          if(cardNumber&gt;1 &amp;&amp; cardNumber&lt;11)
          {
              System.out.print(sign + " ");
              System.out.println(cardNumber);
          }
  
          else if(cardNumber == 11)
          {
              System.out.print(sign + " ");
              System.out.println("Jack");
          }
  
          else if(cardNumber == 11)
          {
              System.out.print(sign + " ");
              System.out.println("Jack");
          }
  
          else if(cardNumber == 12)
          {
              System.out.print(sign + " ");
              System.out.println("Queen");
          }
  
          else if(cardNumber == 13)
          {
              System.out.print(sign + " ");
              System.out.println("King");
          }
  
          else if(cardNumber == 1)
          {
              System.out.print(sign + " ");
              System.out.println("ACE");
          }
  
      }
  
  }
  
  }
  </code></pre>