Best way to check for null values in Java?

后端 未结 16 1249
傲寒
傲寒 2020-12-04 16:30

Before calling a function of an object, I need to check if the object is null, to avoid throwing a NullPointerException.

What is the best way to go abou

16条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-04 17:17

    Simple one line Code to check for null :

    namVar == null ? codTdoForNul() : codTdoForFul();
    

提交回复
热议问题