Can array with zero length exist in Java?

Questions by KanchanT

Showing Answers 1 - 3 of 3 Answers

Ashis

  • Jul 17th, 2006
 

An array of ZERO length can be defined in JAVA. It can be declared in the following ways:- > int arrInt = new int[0];> int arrInt = new Int[]{};But this array will be unchangable.Usage:- Suppose, a method is returning an array of any type. Now under some condition, the method may return NULL. So instead of returning NULL, an array of Zero length can be returned. This will make the method more optimized as returning NULL to an array reference is not at all adviceable.

swapnil

  • Sep 17th, 2013
 

Yes, array size in java is always 0 bz array is start with 0th location

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions