我这异常怎么没捕捉吗

谁学逆向工程 2016-07-27 06:12:16
public class Dd 
{
public static void main(String[] args)
{
try
{
ss();
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
static void ss()
{
throw new Exception();
}
}

...全文
128 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sky_08_06_02 2016-07-28
  • 打赏
  • 举报
回复
引用 3 楼 soton_dolphin 的回复:

static void ss() throws Exception
    {
        throw new Exception();
    }
正解,抛出异常,比须得声明异常,看看JAVA异常声明就懂
anakin_feng 2016-07-27
  • 打赏
  • 举报
回复
引用 4 楼 xiaoyuanyuan2009 的回复:
[quote=引用 3 楼 soton_dolphin 的回复:]

static void ss() 
    {
        System.out.println(1/0);
    }
这种为什么不用写[/quote] 这是运行时异常,异常不一样
谁学逆向工程 2016-07-27
  • 打赏
  • 举报
回复
引用 3 楼 soton_dolphin 的回复:

static void ss() 
    {
        System.out.println(1/0);
    }
这种为什么不用写
soton_dolphin 2016-07-27
  • 打赏
  • 举报
回复

static void ss() throws Exception
    {
        throw new Exception();
    }
谁学逆向工程 2016-07-27
  • 打赏
  • 举报
回复
引用 1 楼 soton_dolphin 的回复:
你这个代码编译能通过??
编译不过,哪错了
soton_dolphin 2016-07-27
  • 打赏
  • 举报
回复
你这个代码编译能通过??

62,625

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧