title: Scanner doesn't update input when returning to method Java
body: <p>I'm writing a word-guessing game code. The main calls the <strong>inputTake</strong> method, which asks for input of a word consisting 5 English letters only, and returns is. Before returning the word, it calls another method, <strong>checkInput</strong>, to make sure the input is valid. If the input isn't valid, the <strong>checkInput</strong> method prints an error message and calls <strong>inputTake</strong> to let the user try again.</p>
  <p>But when the first input is invalid, <strong>checkInput</strong> calls <strong>inputTake</strong> and then the second input is valid everything seems to work alright. The problem is that the method returns the first, invalid input, and not the valid input.</p>
  <p>I tried initializing Scanner in the main and giving it to the method as parameter, but that doesn't help.</p>
  <p>Below is the code I wrote, any thoughts? Any help is welcome</p>
  <hr />
  <p>Main:</p>
  <pre><code>Board board1 = new Board();
          
  String guess = board1.inputTake();
  </code></pre>
  <p>Board:</p>
  <pre><code>// take input - print a message and calls the checkInput method with the String inputed.
  public String inputTake(){
      Scanner scan = new Scanner(System.in);
      String guess;
  
      System.out.println(&quot;choose a word, pick carefully: &quot;);
      guess = scan.next();
      
      // we gotta check whether the input's valid before we return it!
      checkInput(guess);
          
      return guess;
      }
      
      /* checks whether a given String is made out of 5 english language letters. 
       * if it is, program continues normally.
       * if not, it prints error message and calls the InputTake method again.
       */
  public void checkInput(String input) {
      boolean isGood = true;
          
      // check if 5 letters
      if(input.length() != 5)
          isGood = false;
          
      // check if all are english
      if(!input.matches(&quot;[a-zA-Z]+&quot;)) 
            isGood = false;
          
      if(isGood == false) {
          System.out.println(&quot;make sure your guess consists of 5 english letters, try again.&quot;);
          inputTake();
      }
  }
  </code></pre>