问题:为什么两次输出的次序不一样呢?第一次输出有些奇怪,哪位知道的帮忙指点下啦.不胜感激...
执行环境为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)
祝福灾区人民..