public class HelloWorld{
public static void main (String args[]) {
System.out.println ("input, please:");
String str;
str=System.in.read();
System.out.println (str);
}
}

解决方案 »

  1.   

    import java.io.*;public class ScreenIO {
    public static void main(String[] args){
    String str="";
    InputStreamReader in=new InputStreamReader(System.in);
    BufferedReader bfReader=new BufferedReader(in);
    boolean notExit=true;
    System.out.println("===== I/O testing, print \"exit\" to quit. ======");
    //+ "\r\nPlease input:");
    try{
    while(notExit){
    System.out.print("Please input: ");
    str=bfReader.readLine();
    if (str.equalsIgnoreCase("exit")){
    notExit=false;
    }else{
        System.out.println("System output: " + str);
    }
    }
    }catch(IOException ex){

    }
    System.out.println("System exit...");
    }
    }
      

  2.   

    谢谢!
    我还想问的是用System.in下面的方法是否可以实现输入串?
      

  3.   

    可以:
    import java.io.*;
    ....
    BufferReader br=new BufferReader(new InputStreamReaer(System.in));
    String str=br.readLine();
    .....
      

  4.   

    噢!
    再问一下,
    System.out.println()应该是指java的src下的lang目录下的System.java文件的内容吧!
    那.out.println是不是一个方法;
    有没有.in.*的方法?
      

  5.   

    还有与java.io下的方法怎么联系的呢?
      

  6.   

    java api:java.lang.System
    |
    |__public static InputStream inin  是System的一个输入流静态变量,InputStream类型,你可以查看java.io.InputStream类所罗列的该类提供的方法.多看看api文档.
      

  7.   

    是啊!
    我刚刚接触JAVA,在看API文档,不明白就问了。
    我本来以为out.println()是system中的方法,in.*也应该是的,可是在system.java文件中找不到,呵呵!不好意思。