explain that why declaring an array with above syntax nad then calling the length function on it do not gice any exception. i mean explain the above code
Check the args in a main() method started with no args and see if a zero length array is useful.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
We can communicate the same thing to other methods that the JVM communicates to us in main(). Maybe you want an array of widgets sold in New Jersey last week, and there weren't any. Would you rather have to check the count first, handle an exception, or accept a empty array? This speaks to me pretty clearly about what will happen if there are zero or a hundred...
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
They are definately useful. They define a list with no items. If I have a series of steps to execute - lets just say a To-Do list - and that list is an array. What happens when I get to a day with nothing to do? Would I rather have a null value and have to check the null, adjust behavior, etc?
If there's one thing to learn, if your method returns any sort of collection - attempt to return an empty collection rather than null, unless it actually IS null.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus