手指的下面
时间长了,手指会痛
posts - 3,  comments - 2,  trackbacks - 0
抛出异常时,用printStackTrace()来跟踪异常信息,会打印最“子”的信息,
如果不是很有必要,就Exception就OK了

 1public class Demo {
 2    public static void main(String args[]) {
 3        int i = 0;
 4        try {
 5            if (i == 0{
 6                throw new LeafException();
 7            }

 8        }
 catch (TreeException e) {
 9            e.printStackTrace();
10        }

11    }

12}

13
14class TreeException extends Exception{
15    public TreeException () {
16        System.out.println("TreeException()");
17    }

18}

19
20class LeafException extends TreeException{
21    public LeafException () {
22        System.out.println("LeafException()");
23    }

24}

打印结果:
TreeException()
LeafException()
LeafException
        at Demo.main(Demo.java:6)
posted @ 2008-08-19 22:19 xunSir.lee 阅读(83) | 评论 (0)编辑 收藏

<2008年8月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(1)

随笔分类

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜