Create new multidimensional array
Bytecode
Type | Description |
u1 | multianewarray opcode = 0xC5 (197) |
u2 | index |
u1 | <n> |
Stack ..., count1, [count2, ...] => ..., arrayref
Description
The <n> is an unsigned byte which must be greater than or
equal to 1. It represents the number of dimensions of the array to be created. The operand
stack must contain <n> words, which must be of type int
and
nonnegative, each representing the number of components in a dimension of the array to be
created. The count1 is the desired length in the first dimension, count2 in
the second, etc.
All of the count values are popped off the operand stack. The unsigned index is used to get access to class entry. The symbolic reference is resolved . The resulting entry must be an array class type of dimensionality greater than or equal to <n>.
A new multidimensional array of the array type is allocated from the garbage-collected
heap. The components of the array of in the first dimension are initialized to subarrays
of the type of the second dimension, and so on. The components of the first dimension of
the array are initialized to the default initial value for the type of the components. A reference
arrayref to the new array is pushed onto the operand stack.
NegativeArraySizeException - size is less than zero
OutOfMemoryError - insufficient memory to allocate the array
Notes
It may be more efficient to use newarray or anewarray
when creating an array of a single dimension.
The array class referenced via the constant pool instruction may have more dimensions than the dimensions operand of the multianewarray instruction. In that case, only the first dimensions of the dimensions of the array are created.