As I Java programmer I do not understand why you can check if the array is empty using if(array.length). Can someone please elaborate?
Actually array.length is evaluated as true when it has at least one element. When array is empty array.length returns 0 which is evaluated as false.
So the bottom line is you can use if (array.length) to check if array is NOT empty.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With