gpt4 book ai didi

java - System.console() 空指针异常

转载 作者:行者123 更新时间:2023-12-05 01:20:05 26 4
gpt4 key购买 nike

<分区>

这是我的代码:

System.out.println("Enter Username: ");
String unm=System.console().readLine();

System.out.println("Enter Password: ");
char[] pwd=System.console().readPassword();

System.out.println("Welcome: " + "" + " Your password is " + new String(pwd));

为什么会出现此错误?

Enter Username:

Exception in thread "main" java.lang.NullPointerException at Cons.main(Cons.java:13)

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com