title: Java charAt() String index out of range: 0
body: <p>I have this code :</p>
  
  <pre><code>private void submitPstart() {
  
      if (tStock.getText().charAt(0)&gt;='A' &amp;&amp; tStock.getText().charAt(0)&lt;='Z'){
  
  
      }else {
          errorBox ("Uppercase A-Z");
      }
  
      tStock.setText("");
      tStock.setFocus();
  }
  </code></pre>
  
  <p>THis is working but when I try not to put anything on the textbox and press the OK button it crashes. It says:</p>
  
  <p><code>java.lang.StringIndexOutOfBoundsException: String index out of range: 0</code> </p>
  
  <p>and it pointed out to this part: <code>if (tStock.getText().charAt(0)&gt;='A' &amp;&amp; tStock.getText().charAt(0)&lt;='Z')</code></p>
  
  <p>Any help is appreciated. Thanks</p>