凡是调用了会抛出异常的方法都要用try{}catch(){}捕获这个异常

解决方案 »

  1.   

    import java.io.*;
    public class IO
    {
      public static void main(String[] args) throws IOException
      {
         int ch;
         System.out.println("please enter your char");
         ch=System.in.read();
         System.out.println((char)ch);
      }
    }
      

  2.   

    提示你必須捕捉異常
    try
    {
        ch = System.in.read();
    }
    catch(Exception ex)
      

  3.   

    import java.io.*;
    public class IO
    {
      public static void main(String[] args)
      {
         int ch;
         System.out.println("please enter your char");
         try{
           ch=System.in.read();
           System.out.println((char)ch);
         }catch(IOException e){     }
      }
    }
    请捕获异常!!!
      

  4.   

    try
    {
    }
    catch
    {
    }