A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© huhanghao 中级黑马   /  2015-3-15 23:57  /  636 人查看  /  4 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

1、
class Demo
{
        ....省略...
        try
        {
                showExce();
                System.out.println("A");
        }

        ....省略....
}

public static void showExce() throws Exception
{
        throw new Exception();
}



2、
class Demo
{
        ....省略...
        try
        {
                throw new Exception();
                System.out.println("A");
        }

        ....省略....
}

问题:为甚么1当中是对的。2会是错的呢?!感觉都一样啊

4 个回复

倒序浏览
正在看这部分,半懂不懂的
回复 使用道具 举报
System.out.println();输出必须放在main函数中才能执行
回复 使用道具 举报
不知道是不是

点评

不是的。可以在定义的方法中直接处理,不一定非要抛出  发表于 2015-3-16 09:50
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马