他乃乃地,怎么老出现错误,我机子有问题---------- 编译JAVA程序 ----------
test.java:8: unreported exception java.io.IOException; must be caught or declared to be thrown
char ch = (char)System.in.read();
                                         ^
1 error
输出完成 (耗时 3 秒) - 正常终止

解决方案 »

  1.   

    这样
    try{
    char ch = (char)System.in.read();
    System.out.println(ch);
    catch(IOException ioe ){
      System.out.println( "fail" );
    }
      

  2.   

    打少了一个
    应该是这样
    try{
    char ch = (char)System.in.read();
    System.out.println(ch);
    }catch(IOException ioe ){
      System.out.println( "fail" );
    }
      

  3.   

    你加一个 throws IOException吧
    应该就是没有处理I/O异常吧
      

  4.   

    我看的教程上的例子怎么都没写啊,
    《JAVA2应用开发指南》电子工业出版社
    作者这么黑啊
      

  5.   

    也可以
             public static void main String args[]()throws IOException
    {

    char ch = (char)System.in.read();
    System.out.println(ch);
    }
    那样的烂书劝你少看,对读者不负责,越看越烦
      

  6.   

    String args[](),改成(String args[])
    最近比较晕-_-
      

  7.   

    经典代码范例
    try{
      String charSet = "GB2312";
      java.io.InputStreamReader isr = new java.io.InputStreamReader(System.in, charSet);
      java.io.BufferedReader br = new java.io.BufferedReader(isr);
      while((String inputMsg = br.readLine()) != null)
      {
         System.out.println("你输入的是" + inputMsg);
      }
    }catch(Exception ex){};
      

  8.   

    高手们,推荐一本象样点的书吧!!着重基本概念的,有正确可行的例子的java编程思想
      核心技术