确保两个选项之间的执行时间更短的成本:
A:
if(something!=null){ ... }else{ //log }
要么:
B:
try{ something.getField();... }catch(Exception e){ //log }
与基准相关的SO问题: How slow are Java exceptions?
翻译自:https://stackoverflow.com/questions/24200012/what-is-more-time-optimal-if-or-exception