TryCatch 跳转到捕获 [英] TryCatch jump to the catch
本文介绍了TryCatch 跳转到捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 try catch 中跳转到 catch 块:
<块引用>尝试{如果(bla!=)抛出异常();}捕获(异常){//做}
不起作用?
解决方案
bla!=
后面应该跟一个条件,throws
应该是 throw
,Exception()
应该是 new Exception()
,exception
应该是 Exception e
尝试{if (bla != null)//或其他任何东西throw new Exception("抛出异常");} 捕获(异常 e){System.out.println("异常被捕获!");e.printStackTrace();}
How can i jump to the catch block in a try catch :
try{ if(bla!=) throws Exception(); }catch(exception){ //do }
doesn't work ?
解决方案
bla!=
should be followed by a condition, throws
should be throw
, Exception()
should be new Exception()
, exception
should be Exception e
try {
if (bla != null) // or anything else
throw new Exception("Exception thrown");
} catch (Exception e) {
System.out.println("Exception caught!");
e.printStackTrace();
}
这篇关于TryCatch 跳转到捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文