title: Using Try/Catch Inside a For Loop
body: <p>I've been trying to use a try/catch statement in place of multiple if statements in order to catch incorrect input from a user.  The divide by 0 catch is working as intended but the letter instead of number catch will not continue through the for loop.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Run1 {
  
  public static final int its = 4;
  
  public static void main(String[] args) {
      Scanner keyboard = new Scanner(System.in);
      int numerator, denominator;
  
      System.out.println("Enter the numerator");
      numerator = keyboard.nextInt();
  
      for (int i = 0; i &lt; its; i++) {
          try {
              System.out.println("Enter the denominator ");
              denominator = keyboard.nextInt();
              System.out.println("numerator/denominator = " + numerator / denominator);
  
          } catch (java.lang.ArithmeticException e) {
              System.err.println("Don't divide by zero!");
              //i -= 1;
          } catch (java.util.InputMismatchException e) {
              System.err.println("Enter a number!");
              //i -= 1;
          }
      }
  }
  }
  </code></pre>
  
  <p>How come the loop speeds through when a letter is input as the denominator but not when the zero catch is thrown?</p>