<分区>
当您在 IDE 中生成/覆盖新方法、生成 try-catch 构造等时,它们中的大多数(如 Eclipse、Intellij)默认为相当可疑的行为,如返回 null、打印堆栈跟踪并继续、调用 super 方法等。对于例如,如果您在“Thread.sleep(x)”上自动完成,IDE 将为您提供:
try {
Thread.sleep(x);
}catch(InterruptedException e){
e.printStackTrace();
}
在我看来,更明智的做法是在这种情况下throw new AssertionError(e)
,并且throw new AssertionError("not implemented")
在其他情况下。