如题,
运行结果: 

bbb
abcdef

@Test
public void testRuntimeException() {
    int a = 0;
<span style="color:#000080;"><strong>try </strong></span>{
    aaa333();
} <span style="color:#000080;"><strong>catch </strong></span>(Exception ex) {
    System.<span style="color:#660e7a;"><strong><em>out</em></strong></span>.println(<span style="color:#008000;"><strong>"bbb"</strong></span>);
}

System.<span style="color:#660e7a;"><strong><em>out</em></strong></span>.print(<span style="color:#008000;"><strong>"abcdef"</strong></span>);

}

private void aaa333() {
int a = 0;

<span style="color:#000080;"><strong>try </strong></span>{
    <span style="color:#000080;"><strong>int </strong></span>b = <span style="color:#0000ff;">32 </span>/ a;
} <span style="color:#000080;"><strong>catch </strong></span>(Exception ex) {
    <span style="color:#000080;"><strong>throw new </strong></span>RuntimeException(<span style="color:#008000;"><strong>"error;"</strong></span>);
}

}

相关文章:

  • 2022-12-23
  • 2021-11-25
  • 2021-10-15
  • 2022-12-23
  • 2021-05-09
  • 2021-11-16
  • 2022-12-23
  • 2021-12-11
猜你喜欢
  • 2022-02-26
  • 2021-06-15
  • 2021-11-02
  • 2021-09-08
  • 2021-12-08
  • 2022-12-23
相关资源
相似解决方案