iconst_n : push the integer constant 0, 1, 2, 3, 4 or 5 : index :
iconst_0 ; push 0 onto the stack.Note that you could also use:
bipush 0 ; push 0 onto the stackor
sipush 0 ; push 0 onto the stackor
ldc 0 ; push 0 onto the stackalthough these instructions are typically less efficient than the equivalent iconst_n and also take up more bytes in the class file.
iconst_0 ; push 0 onto the stack iconst_1 ; push 1 onto the stack iconst_2 ; push 2 onto the stack iconst_3 ; push 3 onto the stack iconst_4 ; push 4 onto the stack iconst_5 ; push 5 onto the stack
Before | After |
... | <n> |
... |
Type | Description |
u1 | iconst_0 opcode = 0x03 (3) |
u1 | iconst_1 opcode = 0x04 (4) |
u1 | iconst_2 opcode = 0x05 (5) |
u1 | iconst_3 opcode = 0x06 (6) |
u1 | iconst_4 opcode = 0x07 (7) |
u1 | iconst_5 opcode = 0x08 (8) |