title: Need an Input Validation in a Java program(Java 2 SE)
body: <p>I had made a java program in which it is supposed to take input from a user in a GUI frame and store in a .dat file in row and columns. The problem is with this particular code as it is not giving the desired results. the user should be able to enter only numbers between 20 to 30 using a keylistener. the input should not accept any number that is out of this range, i.e, 19 or 31. Eclipse is throwing an error 'invalid character constant'. Is there any way out?</p>
  
  <pre><code>// input validation that restricts user to enter specific number range between 20 and 30
  
  txDeposit.addKeyListener(new KeyAdapter() {
      public void keyTyped(KeyEvent ke) {
          char c = ke.getKeyChar();
          if(!(ke.getKeyChar() &gt;= '20' &amp;&amp; ke.getKeyChar() &lt;= '30')) {
              getToolkit().beep();
              ke.consume();
          }
      }
  });
  </code></pre>