Foredoomed
Foredoomed

Reputation: 2239

What's the difference between java bytecode astore_1 and astore_2

What's the difference between java bytecode astore_1 and astore_2 ?

Upvotes: 6

Views: 1730

Answers (2)

Ernest Friedman-Hill
Ernest Friedman-Hill

Reputation: 81724

The instructions astore_n, for small values of n, are just shorthand equivalents for astore n. Either version stores what's on top of the stack into local variable n.

Upvotes: 11

C. K. Young
C. K. Young

Reputation: 223133

astore_1 is the same as astore 1, and astore_2 is the same as astore 2, except that astore_1 and astore_2 are one byte each, whereas astore is a two-byte instruction.

Upvotes: 5

Related Questions