; to allocate an array like:
; new String[2][5]
bipush 2
bipush 5
multianewarray [[Ljava/lang/String; 2 ; construct both dimensions
; stack now hold a reference two the new two dimensional array.
;
; multianewarray can be used to allocate only some of the
; dimensions of an array. For example, you write:
;
; x = new int[6][3][]
;
; using:
bipush 6
bipush 3
multianewarray [[[I 2 ; allocate 2 of the 3 dimensions
astore_1 ; store array in local variable 1
; then you can create the final dimensions later using
; newarray or anewarray. e.g.
;
; x[0][1] = new int[50];
;
; would be:
aload_1 ; push the array
iconst_0
aaload ; get x[0] - an array of arrays of ints
iconst_1
bipush 50
newarray int ; allocate an array of 50 ints
aastore ; store this in x[0][1]
;
; You can also use multianewarray to create
; single-dimensional arrays. e.g.
bipush 50
multianewarray [Ljava/lang/Thread; 1
; is the same as writing:
bipush 50
anewarray java/lang/Thread
; except that the latter is more efficient.