6 Replies Latest reply on Jun 25, 2007 6:46 PM by 807605

    Exception in thread main java.lang.NullPointerException

    807605
      The complete error is:

      Exception in thread "main" java.lang.NullPointerException
      at java.util.regex.Pattern.<init><Pattern.java:1129>
      at java.util.regex.Pattern.compile<Pattern.java:822>
      at java.util.Scanner$1.create<Scanner.java:391>
      at java.util.Scanner$1.create<Scanner.java:389>
      at sun.misc.LRUCache.forName<LRUCache.java:52>
      at java.util.Scanner.useDelimiter<Scanner.java:1126>
      at Ch2Monogram.main<Ch2Monogram.java:12>

      I get the above error when I run the following program. It compiles fine.

      /* Chapter 2 Sample Program: Displays the Monogram

      File: Step1/Ch2Monogram.java

      */

      import java.util.*;
      class Ch2Monogram {
      public static void main (String[] args) {
      String name;
      Scanner scanner = new Scanner(System.in);
      scanner.useDelimiter(System.getProperty("line.seperator"));
      name = scanner.next();
      System.out.println("Name Entered: " + name);
      }
      }

      What is the problem??