Java实现类似与Oracle控制台登录接收密码功能
import java.io.Console;
public class ConsoleDemo {
public static void main(String[] args) {
Console console = System.console();
String username = console.readLine("请输入用户名:");
char[] password = console.readPassword("请输入密码:");
System.out.println("您的用户名是:" + username);
System.out.print("您的密码是:");
for (int i = 0; i < password.length; i++) {
System.out.print(password[i]);
}
}
}