import java.io.Console;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Console cons = System.console();
String username = cons.readLine("Input your username:"); //会报NullPointerException
char[] passwd = cons.readPassword("Input your password:");
}
}
代码如上所示,运行时提示String username这一行存在NullPointerException空指针的问题,但我不知道问题在哪,求解答
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Console cons = System.console();
String username = cons.readLine("Input your username:"); //会报NullPointerException
char[] passwd = cons.readPassword("Input your password:");
}
}
代码如上所示,运行时提示String username这一行存在NullPointerException空指针的问题,但我不知道问题在哪,求解答
