Prasad Posani wrote:means?? I didn't get you.If you dont mind ,can you please give me a small example if possible.
check out the SDK class java.util.Collections that provides constants for EMPTY_LIST, EMPTY_SET, and EMPTY_MAP. They returned these from methods in order to guarantee a non-null return result, which help client of those methods to avoid explicit Null checks.
Let's say you've got a search method that looks for records matching a particular condition, and returns an array of those records. What would you expect the method to return if there are no matching records?
You could return null. But in that case, whenever you call the method you need to check the return value for null, to avoid NullPointerExceptions. Better to let it return an empty array. That way you can still iterate over it, get the length of the array, etc, safely.