Summary 1. I am import java.io.console,i am not getting any error in my code, code is correct, I thought, It's getting some error in eclipse software... Error :
Exception in thread "main" java.lang.NullPointerException at
loops.Escapey.main(Escapey.java:9)
Coding:
package loops;
import java.io.Console;
public class Escapey {
public static void main(String[] args) {
Console ar = System.console(); // creating a new object for console
String name = ar.readLine("how old are you ?"); //reads a user input
System.out.printf("%s - pretty age",name);
}
}
Ouput : - I except the output how old are you ?? 18 18 - pretty age But the actual output is getting error... Exception in thread "main" java.lang.NullPointerException at loops.Escapey.main(Escapey.java:9)