I am learning about the console in java(version 1.7). when i am calling the any of the function of console class ie. format() or readline(). it throwing the below exception after execution,
in thread "main" java.lang.NullPointerException
at scjp.consol.ProblemConsoleFormat.main(ProblemConsoleFormat.java:20)
Below code that i am running
Console console = System.console();
String username = console.readLine("Please enter user name : ");
System.out.println("You entered : " + username);