I have tried code:
import java.io.Console;
public class Default
{
public static void main(String args[]) throws IOException
{
Console console = System.console();
String testing = console.readLine("Enter Name: ");
System.out.println("Entered Name: "+ testing);
}
}
goes to exception with following error:
Source not found. NullPointerException
I am using Eclipse Juno EE for debugging .. !
And the reference link for above written code is here
解决方案
Are you running your program from an ide as console.readLine returns null when used from an IDE.
If you run it from command line you will not get this error.