title: I want to keep asking for input until valid input provided form scanner
body: <p>I am learning to handle exception and In <code>try</code> block if i get character input in <code>arr[i]</code> then I want the catch block to ask for array input again.
  But the catch block array input code is throwing error.</p>
  
  <pre><code>package Day2;
  
  import java.util.Scanner;
  
  public class LargestinArray {
  public static void main(String[] args) {
      System.out.println("enter 5 number");
      Scanner scanner=new Scanner(System.in);
      int arr[]=new int[5];
  
  
     try{
         for (int i=0;i&lt;5;i++){
             arr[i]=scanner.nextInt();
         }
     }catch (Exception e){
         System.out.println("error");
         for (int i=0;i&lt;5;i++){
             arr[i]=scanner.nextInt();
         }
  
     }
  
      findLarge(arr);
  
  
  }
  
  private static void findLarge(int[] arr) {
      int max=arr[0],min=arr[0];
      for (int i=0;i&lt;arr.length;i++){
          if (arr[i]&gt;max){
              max=arr[i];
          }
          if (arr[i]&lt;min){
              min=arr[i];
          }
      }
      System.out.println("max is"+max+"min is"+min);
  }
  }
  </code></pre>
  
  <p>This is the error i am getting</p>
  
  <pre><code>Exception in thread "main" java.util.InputMismatchException
  at java.base/java.util.Scanner.throwFor(Scanner.java:939)
  at java.base/java.util.Scanner.next(Scanner.java:1594)
  at java.base/java.util.Scanner.nextInt(Scanner.java:2258)
  at java.base/java.util.Scanner.nextInt(Scanner.java:2212)
  at Day2.LargestinArray.main(LargestinArray.java:19)
  </code></pre>