caload :
retrieve character from array : index : visitInsn()
- Description
- Retrieves a character from an array of characters and pushes it on the
operand stack. arrayref is a reference to an array of chars.
index is an int. The arrayref and index are removed from
the stack, and the 16-bit unsigned Unicode character at the given index
in the array is retrieved, zero extended to a 32-bit int, and pushed onto the
stack.
- Example
; This is like the Java code:
; char x = arr[0];
; where x is local variable 2 and arr is a
; char array in local variable 1
aload_1 ; load local variable 1 onto the stack
iconst_0 ; push the integer 0 onto the stack
caload ; retrieve the entry
istore_2 ; store the entry in local variable 2
Exceptions
NullPointerException - arrayref is null
ArrayIndexOutOfBoundsException - index is < 0 or >=
arrayref.length- Notes
- Array indices start at 0 (the first entry in the array is at
index 0).
- See also
- iaload laload faload daload aaload baload saload iastore lastore fastore dastore aastore bastore castore sastore
- Stack
Before
|
After |
index |
value |
arrayref |
... |
... |
... |
- Bytecode
Type
|
Description |
u1
|
caload
opcode = 0x34 (52)
|