Exception 怎么出来的呀,和怎么一些东西,如:方法等,很乱呀,整理一下

解决方案 »

  1.   

    你少了几个}符号,我给你改了一下。可以了。
    class tryarray
    {
      static float c;
      public static void main(String args[])
      {
        BufferedReader readin=new BufferedReader(new InputStreamReader(System.in));
        float a[]={1F,5.6F,7F,0F,6F};
        float b[]={3F,5F,7F,8F};
        do{
          try
          {
            System.out.println("Do NOT Exit Y");
            String input3=readin.readLine();
            if(!input3.toUpperCase().equals("Y"))
            {
              System.exit(0);
            }
            int i;
            for(i=0;i<4;i++)
              System.out.println("Resolt N1/N2=  "+division(a[i],b[i]));
          }
          catch(IOException e)
              {System.out.println(e);}
          catch(NumberFormatException e)
              {System.out.println(e);}
          catch(ArithmeticException e)
          {
            System.out.println("error!");
            System.out.println(e);
            e.printStackTrace(System.out);
          }
          catch(IndexOutOfBoundsException e)
              { System.out.println("array over");}
          finally
          {
            System.out.println("continue");
          }    }while(true);
      }
      static float division(float a1,float a2) throws ArithmeticException
      {
        if(a2==0) throw new ArithmeticException("can't be 0");
        float k;
        k=a1/a2;
        return k;
      }
    }
      

  2.   

    tryarray.java(6,5) : error J0049: Undefined name 'BufferedReader'
    tryarray.java(6,5) : error J0044: Cannot find definition for class 'BufferedRead
    er'
    tryarray.java(22,13) : error J0049: Undefined name 'IOException'
    tryarray.java(22,13) : error J0044: Cannot find definition for class 'IOExceptio
    n'
      

  3.   

    import java.io.*;
    还是要的.