title: is this code for parsing from string method to integer answer ok?
body: <p>So I'm making a programme in java for a college assignment.</p>
  
  <p>in my main menu i have a choice option that a user can choose from 1-7 and to validate that I created this </p>
  
  <pre><code>public static String validateChoice(int floor, int roof) { // method for validating user input. floor = lowest possible value user can input &amp; roof is maximum possible value user can input
      int choice = -1;
      String errorMessage = "Error: only numbers between " + floor + " and " + roof + " are accepted";
  
      while(true) { // keeps looping until valid choice number is met
          while(!intScanner.hasNextInt()) { // will keep looping if user doesn't input an int e.g user inputs string
              intScanner.next(); // if user inputs string then eat that up and print error message and loop again
              System.out.println(errorMessage);
          }
          choice = intScanner.nextInt(); 
  
          if(choice &gt;= floor &amp;&amp; choice &lt;= roof) // if choice is inbetween floor and roof 
              return Integer.toString(choice); // return that value parsed as a string (cause this method is string)
          else
              System.out.println(errorMessage);
  
      }
  }
              System.out.println(errorMessage);
  </code></pre>
  
  <p>and that is returned into this</p>
  
  <pre><code>choice = Integer.parseInt(validateChoice(floor, roof));
  </code></pre>
  
  <p>My question is, is it ok to parse from a string method to an int variable. I'll admit i'm fairly ignorant in java so I would like your opinions on whether it's a good idea to write programmes like that. My thought process was is like it's two birds with one stone. It validates ints and returns an error when user input is wrong in one method</p>