+ 1
Hey guys , how to check if an element in an array of integer is empty? Is it equal to null or 0?
4 Answers
+ 3
Integer value by default is 0 so if a value at a certain index is not assigned then it will have 0. To check if an element is 0 then you can simply iterate over the array and check if array[i]==0.
An array of 'n' elements will have index from 0 to n-1 which is end of array.
+ 2
empty != null
If an array is empty, the length will be 0. So you can check by if(array.length == 0)
+ 2
CarrieForle no I'm not talking about the length of the array but an element , i mean how to check if there is no next element in an array
+ 2
Avinesh thank you