this question has answer here:
- use of array of 0 length 3 answers
i confused mean ::
int[] array = new int[0]; how many bytes allocated here? or nothing allocated in memory? going underneath?
this zero-length array.
how many bytes allocated platform specific, still have array here, short one. in general, array in java needs
fixed overhead + length * componentsize bytes (and there maybe padding).
also note since arrays cannot resized in java, , zero-length array cannot have elements updated, makes immutable , don't need more 1 instance of them in whole program, can use static singleton arrayutils.empty_int_array, saving "fixed overhead".
Comments
Post a Comment