问题:为什么两次输出的次序不一样呢?第一次输出有些奇怪,哪位知道的帮忙指点下啦.不胜感激...
执行环境为eclipse3.2,jdk1.6.06;程序如下:
class MyException extends Exception{
public MyException()
{
System.out.println("int the Exception ...");
}
public MyException(String msg){
super(msg);
}
}
public class Inheriting {
public static void f() throws MyException{
System.out.println("throwing MyException from f()");
throw new MyException();
}
public static void g() throws MyException{
System.out.println("Throw MyException from g()");
throw new MyException("originated in g()");
}
public static void main(String[] args){
try{
f();
}catch(MyException e){
e.printStackTrace();
}
try{
g();
}catch(MyException e){
e.printStackTrace();
}
}
}第一次执行输出结果:
c09.MyException
at c09.Inheriting.f(Inheriting.java:11)
at c09.Inheriting.main(Inheriting.java:19)
c09.MyException: originated in g()
at c09.Inheriting.g(Inheriting.java:15)
at c09.Inheriting.main(Inheriting.java:24)
throwing MyException from f()
Throw MyException from g()
第二次执行输出结果:
throwing MyException from f()
c09.MyException
at c09.Inheriting.f(Inheriting.java:11)
at c09.Inheriting.main(Inheriting.java:19)
Throw MyException from g()
c09.MyException: originated in g()
at c09.Inheriting.g(Inheriting.java:15)
at c09.Inheriting.main(Inheriting.java:24)
祝福灾区人民..
执行环境为eclipse3.2,jdk1.6.06;程序如下:
class MyException extends Exception{
public MyException()
{
System.out.println("int the Exception ...");
}
public MyException(String msg){
super(msg);
}
}
public class Inheriting {
public static void f() throws MyException{
System.out.println("throwing MyException from f()");
throw new MyException();
}
public static void g() throws MyException{
System.out.println("Throw MyException from g()");
throw new MyException("originated in g()");
}
public static void main(String[] args){
try{
f();
}catch(MyException e){
e.printStackTrace();
}
try{
g();
}catch(MyException e){
e.printStackTrace();
}
}
}第一次执行输出结果:
c09.MyException
at c09.Inheriting.f(Inheriting.java:11)
at c09.Inheriting.main(Inheriting.java:19)
c09.MyException: originated in g()
at c09.Inheriting.g(Inheriting.java:15)
at c09.Inheriting.main(Inheriting.java:24)
throwing MyException from f()
Throw MyException from g()
第二次执行输出结果:
throwing MyException from f()
c09.MyException
at c09.Inheriting.f(Inheriting.java:11)
at c09.Inheriting.main(Inheriting.java:19)
Throw MyException from g()
c09.MyException: originated in g()
at c09.Inheriting.g(Inheriting.java:15)
at c09.Inheriting.main(Inheriting.java:24)
祝福灾区人民..
解决方案 »
- 如何从乱码文件从删去不需要的字节
- 组件JScrollPane ,接口 Scrollable 的问题 ,请教 Swing 高手
- 这个问题超级狂燥!学习JAVA都会遇到的问题!大家来看看哦!
- 初学java 请教一个比较幼稚的问题
- 求一分页显示bean,要求传入的参数是ArrayList结果集
- TextArea的鼠标右键事件
- 接口问题
- JAVA Swing中JScrollPane与JPanel配合使用时的问题
- 关于HashMap()里的values()方法的一个深深的问题!
- ———《菜菜鸟》菜级问题二:有参数程序执行不成功。—《来者有分》——
- 大家看看这个程序错在何处?谢谢
- 急,有没有人能2天内帮我写个人人对战的五子棋游戏
int the Exception ...
MyException
at Inheriting.f(Inheriting.java:13)
at Inheriting.main(Inheriting.java:21)
MyException: originated in g()
at Inheriting.g(Inheriting.java:17)
at Inheriting.main(Inheriting.java:26)
Throw MyException from g()
我的结果