RT
- Java code
public class scannerAndconsol { public static void main(String[] args) { // TODO Auto-generated method stub Console cons =System.console(); String psw = new String(cons.readPassword()); System.out.println(psw); }}
------解决方案--------------------------------------------------------
cons对象为空了,你是直接在IDE里运行的吧,这样运行是没有Console对象的,你可以在IDE里编译好以后到命令行里直接用java命令运行