title: while true try catch nested
body: <p>I'm new to Java. I want the code to repeat at the point where the user input is the wrong type rather than starting from the beginning. When at "enter b: " or "Enter c: " it goes back to the beginning "Enter a: ". I want it to repeat only, where the user input is a, b, c. Thanks in advance.</p>
  
  <pre><code>public static void main(String[] args)
  {
  Scanner sc = new Scanner(System.in);
  boolean itsANumber = true;
  while (itsANumber)
  {
      System.out.print("Enter a: ");
  
      try
      {
      a = Double.parseDouble(sc.nextLine());
  
      System.out.print("Enter b: ");
      try
      {
          b = Double.parseDouble(sc.nextLine());
  
          System.out.print("Enter c: ");
          try
          {
          c = Double.parseDouble(sc.nextLine());
          if (a == 0)
          {
              aZero();
          } else
  
          {
              aNotZero();
          }
  
          } catch (NumberFormatException nfe) 
          {
          System.out
              .println("That's not a number, please try again!");
          }
  
      } catch (NumberFormatException nfe) 
      {
          System.out
              .println("That's not a number, please try again!");
      }
  
      } catch (NumberFormatException nfe) 
      {
      System.out.println("That's not a number, please try again!");
      }
  }
  
  }
  </code></pre>