我需要null检查嵌套方法调用,如下所示:
if (getShopModel() != null && getShopModel().getType() != null)
我不认为这是最好的方法,因为我两次调用getShopModel可能相当昂贵.
有没有更好的方法来检查getShopModel().getType(),这样我只需要调用一次getShopModel()?
java syntax error-handling null
error-handling ×1
java ×1
null ×1
syntax ×1