> create an array and then discover there are no values to place in it.
I mean you can't change the size of an array after you've created it, so if you create an array with a certain size intending to put values in it, then discover there aren't any values, you've still got a non-zero size array...
CL-USER 9 > (make-array 0 :adjustable t :fill-pointer 0)
#()
CL-USER 10 > (vector-push-extend 'foobar *)
0
CL-USER 11 > **
#(FOOBAR)> comfortable making zero-length simple-vectors
Btw., CL allows also zero-dimensional arrays:
CL-USER 3 > (make-array '())
#0ANILNot in Java, no.
An ArrayList is an object which represents a variable length random-access list and does not support basic types (int, double etc.) An array is fixed-length and supports basic types. It is not an object per se.
The closest analog to an ArrayList in Lisp is an extensible vector, and the closest analog to an array is a simple-vector.
> Btw., CL allows also zero-dimensional arrays:
As any decent language would!
> This code will not result in an error message. This surprising feature is used primarily by code generators, which might create an array and then discover there are no values to place in it.
What? How can someone at Oracle have written this?
Zero-length arrays are used all the time when you call a function asking for an array of "the latest stuff" and it needs to be an array, not an ArrayList say (maybe it's an array of bytes). If there's no stuff, you get a zero-length array of course. The myriad foo.toArray(...) functions in Java's library do this for example.