title: How can I make a do while loop with an exception catch, continuous?
body: <p>I try to catch the exception which finally works but now I need to figure out how to make it loop. ALso, how would I be able to get user input(int select) to the outside of the loop? I can try creating a new function, that might do the trick.</p>
  
  <pre><code>do {
      System.out.print("How many integers shall we compare? (Enter a positive integer): ");
      try {
          select = intFind.nextInt();
      } catch (InputMismatchException e) {
          // Display the following text in the event of an invalid input
          System.out.println("Invalid input!");
          intFind.nextLine();
      }
  } while (select &lt; 0);
  </code></pre>
  
  <p>Then</p>
  
  <pre><code>do
              {
                  System.out.print("How many integers shall we compare? (Enter a positive integer): ");
                  try {
                      b = Get();
                  }
                  catch (InputMismatchException e) {
                      // Display the following text in the event of an invalid input
                      System.out.println("Invalid input!");
  
                      intFind.nextLine();
                  } copySel = b;  
              }while(select &lt; 0);
  </code></pre>
  
  <p>and </p>
  
  <pre><code>static int Get()
      {
          Scanner intFind = new Scanner(System.in);
          int select;
          select = intFind.nextInt();
          return select;
      }
  </code></pre>