提问代码如下:public class Exceptionx  
{
public static void main(String[] args) throws IException
{
int a=10;
int b=0;
//IExecption e=new IExecption();
int c;
try{  c=a/b;

}
catch (IException e)
{
System.out.println("oo");
}
}}
 class IException extends Exception
{
   public static void main(String[] args) 
{
   }
   public void IException()
   {
   System.out.println("ok");
   }
  
};

解决方案 »

  1.   

    public static void main(String[] args) throws IException这也能行?没看出来楼主想问什么。
      

  2.   

    在 catch (IException e) 这一句上有问题
      

  3.   

    抱错:
    Exceptionx.java:12: exception IException is never thrown in body of correspondin
    g try statement
                    catch (IException e)
                    ^
    1 error
      

  4.   

    public class Exceptionx {
        public static void main(String[] args)
            throws IException {
            int a = 10;
            int b = 0;
            IException e = new IException();
            int c;
            try {
                c = a / b;
            } catch (Exception ie) {
                throw e;
            }
        }}class IException extends Exception {
        public static void main(String[] args) {
        }    public IException() {
            System.out.println("ok");
        }}