title: Integer.parseInt(scanner.nextLine()) vs scanner.nextInt()
body: <p>My professor tends to do the following to get a number from the user:</p>
  
  <pre><code>Scanner scanner = new Scanner(System.in);
  Integer.parseInt(scanner.nextLine());
  </code></pre>
  
  <p>What are the benefits as opposed to simply doing <code>scanner.nextInt()</code> ?</p>
  
  <p><code>java.util.Scanner.java</code> has the following in it:</p>
  
  <pre><code>public int nextInt() {
      return nextInt(defaultRadix);
  }
  
  public int nextInt(int radix) {
      // Check cached result
      if ((typeCache != null) &amp;&amp; (typeCache instanceof Integer)
          &amp;&amp; this.radix == radix) {
          int val = ((Integer)typeCache).intValue();
          useTypeCache();
          return val;
      }
      setRadix(radix);
      clearCaches();
      // Search for next int
      try {
          String s = next(integerPattern());
          if (matcher.group(SIMPLE_GROUP_INDEX) == null)
              s = processIntegerToken(s);
          return Integer.parseInt(s, radix);
      } catch (NumberFormatException nfe) {
          position = matcher.start(); // don't skip bad token
          throw new InputMismatchException(nfe.getMessage());
      }
  }
  </code></pre>
  
  <p>As I see it, <code>Scanner</code> calls Integer.parseInt() itself as well, on top of additional hocus pocus. Are there significant performance gains in doing simply <code>Integer.parseInt(scanner.nextLine())</code> ? Are there on the other hand any drawbacks?</p>
  
  <p>How about when scanning through a file with significant amount of data, and not a user input?</p>