Java - is there any reason to check if a singleton is null twice?

前端 未结 5 1959
傲寒
傲寒 2020-12-18 00:42

I have come across some code, where the developer is constantly checking if the singleton is null twice with a nested if - like in the code below:

private st         


        
5条回答
  •  旧时难觅i
    2020-12-18 00:55

    This does not make any sence unless the singleton is a property which creates the instance in the getter, but even then this would not make sense then the rest of the code would be unreachable.

提交回复
热议问题