请 查看  java doc 里面 system.in

解决方案 »

  1.   

    import java.io.*;/**
     * @author Administrator
     *
     * To change the template for this generated type comment go to
     * Window - Preferences - Java - Code Generation - Code and Comments
     */
    public class aa {
    public static void main(String args[]) {
    try {
    BufferedReader in =
    new BufferedReader(new InputStreamReader(System.in));
    for (;;) {
    System.out.print("name:");
    String line = in.readLine();
    if ((line == null) || line.equals("aaa"))
    break;
    }
    for (;;) {
    System.out.print("password:");
    String line = in.readLine();
    if ((line == null) || line.equals("123")){
    System.out.print("success!");
    break;
    }
    System.out.println("fail!");
    }
    in.close();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    }