title: Asking user to enter the input again after he gives a wrong value for the Input. InputMismatchException?
body: <p>I have created the following class for Inputting a user's age and then displaying appropriate info in the console. </p>
  
  <p>On running this program , the console asks "Please Enter your Age : "</p>
  
  <p>If the user enters an Integer for eg: 25 , the executed class displays " Your age is : 25" in the console. </p>
  
  <p>If the user enters a non-integer number , the console displays:
  Age should be an Integer
  Please Enter your Age:</p>
  
  <p>But I am not able to enter anything through the keyboard when I place my cursor next to "Please Enter your Age: ". </p>
  
  <p>I want the user to be able to enter his age again, &amp; if he enters an integer it displays the proper output but if he enters a non-integer the console should ask him again for the age.</p>
  
  <p>If you look at my code I'm setting the value of the variable 'age' by calling the function checkAge() inside the else block in my main function.</p>
  
  <p>Can anybody tell me where I am going wrong?</p>
  
  <pre><code>public class ExceptionHandling{
  
      static Scanner userinput = new Scanner(System.in);
  
      public static void main(String[] args){ 
          int age = checkAge();
  
          if (age != 0){
              System.out.println("Your age is : " + age);         
          }else{
             System.out.println("Age should be an integer");
             age = checkAge();
          }
      }
  
      public static int checkAge(){
          try{            
              System.out.print("Please Enter Your Age :");
              return userinput.nextInt();
          }catch(InputMismatchException e){
              return 0;
          }
      }
  }
  </code></pre>