try/catch vs null check in java

前端 未结 10 2208
心在旅途
心在旅途 2020-12-01 14:05

Sometimes I face I must write a piece of code like this (usually it have more nested if and more complex structure but for the example is enought)

public voi         


        
10条回答
  •  再見小時候
    2020-12-01 14:29

    A code should never include exception handlers for unchecked exceptions. A null check should always be used for an object reference which has a chance of being null.

提交回复
热议问题