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

后端 未结 9 1063
情深已故
情深已故 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:16

    Fighting whether the code is compiling or not I would say create a array of sixe 5 add 2 values and print them , you will get the two values and others are null. The question is although the size is 5 but there are 2 objects in the array . How to find how many objects are present in the array

提交回复
热议问题