/** This class shows how to read user input from the command line using Console class: java.io.Console Refer to API docs for specifics. */ import java.io.Console; public class ReadConsole { public static void main(String[] args) { // Console is useful for reading lines and passwords Console c = System.console(); String name = c.readLine("Enter your name: "); char[] passwd = c.readPassword("Enter your password: "); String pword = new String(passwd); System.out.println("Hello " + name + ", your password is: " + pword); } }