+ 1

Hey guys , how to check if an element in an array of integer is empty? Is it equal to null or 0?

3rd Apr 2020, 4:37 PM
David Bukedi Diela
David Bukedi Diela - avatar
4 Respuestas
+ 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.
3rd Apr 2020, 5:25 PM
Avinesh
Avinesh - avatar
+ 2
empty != null If an array is empty, the length will be 0. So you can check by if(array.length == 0)
3rd Apr 2020, 5:00 PM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 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
3rd Apr 2020, 5:20 PM
David Bukedi Diela
David Bukedi Diela - avatar
+ 2
Avinesh thank you
3rd Apr 2020, 5:27 PM
David Bukedi Diela
David Bukedi Diela - avatar