How to check if array element is null to avoid NullPointerException in Java

后端 未结 9 1075
情深已故
情深已故 2020-12-16 13:08

I have a partially nfilled array of objects, and when I iterate through them I tried to check to see whether the selected object is null before I do other stuff

9条回答
  •  难免孤独
    2020-12-16 13:19

    The example code does not throw an NPE. (there also should not be a ';' behind the i++)

提交回复
热议问题