newarray | |
atype |
Stack ..., count ..., arrayref
Description
The count must be of type int
. It is popped off the operand stack. The count represents the number of elements in the array to be created.
The atype is a code that indicates the type of array to create. It must take one of the following values:
Array Type | atype |
T_BOOLEAN
|
4
|
T_CHAR
|
5
|
T_FLOAT
|
6
|
T_DOUBLE
|
7
|
T_BYTE
|
8
|
T_SHORT
|
9
|
T_INT
|
10
|
T_LONG
|
11
|
A new array whose components are of type atype, of length count, is allocated from the garbage-collected heap. A reference
arrayref to this new array object is pushed into the operand stack. All of the elements of the new array are initialized to the default initial values for its type (§2.5.1).
Runtime Exception
If count is less than zero, newarray throws a NegativeArraySizeException
.
Notes
In Sun's implementation of the Java Virtual Machine, arrays of type boolean
(atype is T_BOOLEAN
) are stored as arrays of 8-bit values and are manipulated using the baload and bastore instructions, instructions that also access arrays of type byte
. Other implementations may implement packed boolean
arrays; the baload and bastore instructions must still be used to access those arrays.