title: Scanner.skip() in Java
body: <p>I'm very new to Java and trying to understand the Scanner class. I'm using the <a href="http://www.tutorialspoint.com/java/util/scanner_skip_pattern.htm" rel="nofollow">example code</a> to learn about the skip(String Pattern) method of the Scanner class. I tweaked the code a little and changed it to</p>
  
  <pre><code>import java.util.*;
  
  public class ScannerDemo {
  
     public static void main(String[] args) {
  
        String s = "Hello World! 3 + 3.0 = 6.0 true ";
  
        // create a new scanner with the specified String Object
        Scanner scanner = new Scanner(s);
  
        // changed the string to skip
        scanner.skip("World");
  
        // print a line of the scanner
         System.out.println("" + scanner.nextLine());
  
        // close the scanner
        scanner.close();
     }
  }
  </code></pre>
  
  <p>The output I was expecting is</p>
  
  <pre><code>Hello ! 3 + 3.0 = 6.0 true
  </code></pre>
  
  <p>But I get <code>NoSuchElementException</code>. Can some one point out my mistake please.</p>