Community
Participate
Working Groups
Build Identifier: M20110210-1200 When I run this code: import java.util.*; import java.io.*; import java.lang.*; public class TestThree { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print ("What's your name?"); String name = in.nextLine(); //String firstName = in.next(); System.out.print("How old are you?"); int age = in.nextInt(); System.out.println("Hello, " + name + ", next year you will be " + (age + 1) + " years old."); Console cons = System.console(); System.out.println("Enter a password:"); char[] charPasswd = cons.readPassword("[%s]", "Password :"); String strPassword = null; StringBuilder builder = new StringBuilder(); builder.append(charPasswd); strPassword = builder.toString(); System.out.println("Password keyed in: " + strPassword); } } I get this output: What's your name?Jon C. How old are you?31 Hello, Jon C., next year you will be 32 years old.Exception in thread "main" java.lang.NullPointerException at TestThree.main(TestThree.java:21) Enter a password: The code snippet works as expected when compiling through the command line (javac.exe) Reproducible: Always
Created attachment 192904 [details] Code snippet
*** This bug has been marked as a duplicate of bug 122429 ***