0

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);
Madhawa Priyashantha
  • 9,633
  • 7
  • 33
  • 60

0 Answers0