Eclipse生成的默认异常处理代码如下所示:
try {
methodThrowsACheckedException();
} catch (SomeCheckedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
如果Eclipse生成以下代码会不会更好?
try {
methodThrowsACheckedException();
} catch (SomeCheckedException e) {
// TODO Auto-generated catch block
throw new RuntimeException(e);
}
答案 0 :(得分:5)
您可以将eclipse配置为您的选择。查看Code Template-> Catch Block Body
Preferences->Java->Code style