import java.io.*;public class Echo{
public static void main (String[] args) {

throws IOException{
BufferedReader in=
new BufferedReader(
new InputStreamReader(System.in));

String s;

while((s=in.readLine()).length()!=0)
System.out.println(s);
}
}
}//运行出错如下:
D:\My Documents\JCreator Pro\MyProjects\IOTester\Echo.java:6: 非法的表达式开始
        throws IOException{
                ^
D:\My Documents\JCreator Pro\MyProjects\IOTester\Echo.java:16: 需要 ';'
}
^
2 错误

解决方案 »

  1.   


    import java.io.*;class Echo {    public static void main(String[] args) throws IOException {
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));        String s;        while ((s = in.readLine()).length() != 0) {
                System.out.println(s);
            }
        }
    }主语编码格式和语法
      

  2.   

    public static void main (String[] args) //{ 这个分号是多余的throws IOException{ 
      

  3.   


    public class Echo{ 
      public static void main (String[] args) throws IOException{ 
      BufferedReader in=  new BufferedReader( new InputStreamReader(System.in));    String s;    while((s=in.readLine()).length()!=0) 
      System.out.println(s); 
       } 
      }