请问异常继承的问题? 这句话的翻译肯定有些问题。我的理解是这样的比如父类里有函数f() throws ex1那子类里不能再f() throws ex1,就是说异常不能这样传递抛出,不知道楼主认为如何? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 楼上说的这样可以呀?如下:class ThrowException1{public int x; public void throw1() throws ArithmeticException {x=0; x=3/x; x=1; System.out.println("x="+x); }}public class ThrowException extends ThrowException1{ public void throw1() throws ArithmeticException {x=0; x=3/x; x=1; System.out.println("x="+x); } public static void main(String[] args) { ThrowException t = new ThrowException(); try{ t.throw1(); } catch (Exception e){System.out.println("begin!!!!!!") e.printStackTrace(); System.out.println("get message="+e.getMessage()); } } }编译运行都正常呀? sorry是我的理解有问题了。是这样的,如果父类函数不抛出异常,子类也不能抛出。如果父类函数抛出异常,那子类只能抛出同样的异常,就是说只有我写的那种情况才是没错误的。ft理解有问题,sorry 初来乍到~! swing 高手请进,帮帮忙啊………………!! 两道简单的面试题 我写的APPLET程序怎么不能运行呢 怎么就读不出来呢??高手请进来指导一下吧!~(在线等待) 简单的问题:请教熟悉JCreator的朋友 短信编码问题: 在jb9中怎么配置weblogic8? 关于socket 通讯问题,请进。。。 急求JBuilder6 Enterprise的key或注册机 请版主,各位高手帮忙!!急!! 散分!!郁闷,本来是三颗星的,结果换了一下名称,竟然少了两颗星~~~~抗议~~up着有分!!!!!!!!!!!!!!!
如下:class ThrowException1
{public int x;
public void throw1() throws ArithmeticException
{x=0;
x=3/x;
x=1;
System.out.println("x="+x);
}
}
public class ThrowException extends ThrowException1
{ public void throw1() throws ArithmeticException
{x=0;
x=3/x;
x=1;
System.out.println("x="+x);
}
public static void main(String[] args)
{ ThrowException t = new ThrowException();
try{
t.throw1(); }
catch (Exception e){System.out.println("begin!!!!!!")
e.printStackTrace();
System.out.println("get message="+e.getMessage());
}
}
}
编译运行都正常呀?