try{
    int b = System.in.read();
   }
    
    catch(Exception ex)
    {
    }

解决方案 »

  1.   

    C:\Test.java:9: unreported exception java.io.IOException; must be caught or declared to be thrown
     int a = System.in.read();
                           ^
    1 errorProcess completed.
      

  2.   

    我也初学,是不是你MAIN函数没有写
    throws IOException啊?
      

  3.   

    呵呵,编译时已告诉你是要把int a = System.in.read();放在try catch 块中,因为这条语句会抛异常
      

  4.   

    try {
        int a = System.io.read();
        int a = System.in.read();
        int a = System.io.readln();
        int a = System.in.readln(); 
        int a = System.io.readlnteger();
        int a = System.in.readlnteger();
    }
    catch(Exception e)
    {
    }或者public static void main(String[] args) throws Exception
      

  5.   

    你看
    must be caught or declared to be thrown就应该catch一下或throws一下了,
    提示的还是很清的,java不像C++那样,它是强制性的,对错误捕捉。
      

  6.   

    那为什么在Linux下使用Java(版本不明)甚至加载的是Prog1Tools.tools
    为什么使用以下命令也没有问题呢?
    System.iotools.readinteger();
    System.out.println();
      

  7.   

    为什么还不对?C:\Test.java:12: cannot resolve symbol
    symbol  : method read (java.lang.String)
    location: class java.io.InputStream
     int a = System.in.read("dqawefadfa");
                      ^
    1 errorProcess completed.