Java: How to check for null pointers efficiently

前端 未结 14 1773
清歌不尽
清歌不尽 2020-12-03 01:17

There are some patterns for checking whether a parameter to a method has been given a null value.

First, the classic one. It is common in self-made code

14条回答
  •  一向
    一向 (楼主)
    2020-12-03 02:02

    The first method is my preference because it conveys the most intent. There are often shortcuts that can be taken in programming but my view is that shorter code is not always better code.

提交回复
热议问题