title: How to validate string if the first 3 positions are letters
body: <p>I'm trying to validate a string entered by a user. The user must enter a string with 7 characters; the string first 3 characters must be letters and the last 4 must be numbers. </p>
  
  <p>I wrote this piece of code( as a method ) but for some reason it accepts the first character as a number ( which it's suppose to be a letter ) and the rest are numbers. For example :</p>
  
  <pre><code>Please enter word : **1gy2345**
  </code></pre>
  
  <p>This will enter the loop, as wanted, and move on into the next method in the main. </p>
  
  <p>If the user enters a word that its length is bigger than 7 it will ask him to enter a valid word. </p>
  
  <p>For example :</p>
  
  <pre><code>Please enter word : **bob12345**
  The word entered is invalid. Please enter a word beginning with 3 letters and ending with 4 numbers ( The word must be 7 characters long ).
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>public static final String solicitationMessage = " Please enter word ";
  
      public static final String errorMessage = " The word entered is invalid. Please enter a word beginning with 3 letters and ending with 4 numbers ( The word must be 7 characters long ).
  
      public static final int lengthOfString = 7;
  
      public static String validateString(String solicitationMessage, String errorMessage, int lengthOfString) {
  
          System.out.print(solicitationMessage);
  
          String word = keyboard.nextLine();
  
          while (!( word.length() == lengthOfString )) {
              if (((word.charAt(0) &lt;= 'a' || word.charAt(0) &gt;= 'z') || (word.charAt(1) &lt;= 'a' || word.charAt(1) &gt;= 'z')
                      || (word.charAt(2) &lt;= 'a' || word.charAt(2) &gt;= 'z'))) {
                  System.out.print(errorMessage);
                  System.out.print(solicitationMessage);
                  word = keyboard.nextLine();
              }
          }
          return word;
      }
  </code></pre>
  
  <p>However, if I enter a string higher than the 7 limit character it will ask me again the enter a valid string like it's suppose to do. </p>
  
  <p>The use of regex is not permitted. </p>
  
  <p>Any help ?</p>