Tuesday 17 May 2011

Arrays of length 0

It is legal to have arrays of length 0. Such an array can be useful if you write a method that computes an array result and the result happens to be empty. You construct an array of length 0 as

new zeroArr[0];

Note that an array of length 0 is not the same as null.

No comments:

Post a Comment