title: Java validation sc.next(); method
body: <p>I'm trying to create a solid validation process and the only thing i can't understand it's sc.next(); method. Without this method i can't redirect user back to the scanner input. Please, explain, what this method is actually working for?</p>
  
  <pre><code>public static void main(String[] args) {
      Scanner input = new Scanner (System.in);
  
      int a;
      int b;
  
      do {
          System.out.println("Enter two integer digits");
          while (!input.hasNextInt()) {
              System.out.println("An error has occured. Enter two integer digits");
              input.next(); // What this method is actually working for?
          }
          a = input.nextInt();
          b = input.nextInt();
      } while (a == 0 &amp;&amp; b == 0);
  }
  </code></pre>
  
  <p>}</p>