我们可以在catch block 中编写任何实现代码吗? catch block 中要使用哪些规则来实现?
try{
resultado = (T) mensaje.getBody(clase);
}
catch(Exception ex){
resultado = null;
this.destruye();
throw ex;
}
最佳答案
您可以在 catch block 中编写您想要的所有代码。
Exception handlers can do more than just print error messages or halt the program. They can do error recovery, prompt the user to make a decision, or propagate the error up to a higher-level handler using chained exception
请记住,只有抛出异常时才会执行此代码。
关于java - 与try和catch相关的异常处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30476273/