java-Scaner和Console类对象

Scanner sc = new Scanner(System.in);
System.out.println("name is:");
String name = sc.nextLine();

Scaner类在控制台输入可见,

j2se 6 引入了Console类来实现从控制台读取密码

Console cs = System.console();
String name = cs.readLine("name is: ");
char[] ps = cs.readPassword("password is:");

输入不显示值;在win系统的dos窗口下运行;

 

posted @ 2015-06-24 13:46  MyCloud  阅读(456)  评论(0编辑  收藏  举报