---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 16 Edition"
java_version: 16
chapter: "Chapter 6. The Java Virtual Machine Instruction Set"
section: "6.5.astore_n"
heading: "astore_<n>"
parent: "6.5. Instructions"
source: https://docs.oracle.com/javase/specs/jvms/se16/html/jvms-6.html#jvms-6.5.astore_n
id: "6.5.astore_n"
url: https://jvm.obfuscated.software/jvms/se16/6.5.astore_n.html
raw: https://jvm.obfuscated.software/jvms/se16/6.5.astore_n.md
---

# astore\_\<n>

## Operation

Store `reference` into local variable

## Format

```
astore_<n>
```

## Forms

*astore_0* = 75 (0x4b)

*astore_1* = 76 (0x4c)

*astore_2* = 77 (0x4d)

*astore_3* = 78 (0x4e)

## Operand Stack

..., *objectref* →

...

## Description

The <*n*> must be an index into the local variable array of the current frame ([§2.6](2.6.md)). The *objectref* on the top of the operand stack must be of type `returnAddress` or of type `reference`. It is popped from the operand stack, and the value of the local variable at <*n*> is set to *objectref*.

## Notes

An *astore\_\<n>* instruction is used with an *objectref* of type `returnAddress` when implementing the `finally` clauses of the Java programming language ([§3.13](3.13.md)).

An *aload\_\<n>* instruction ([§*aload\_\<n>*](6.5.aload_n.md)) cannot be used to load a value of type `returnAddress` from a local variable onto the operand stack. This asymmetry with the corresponding *astore\_\<n>* instruction is intentional.

Each of the *astore\_\<n>* instructions is the same as *astore* with an *index* of <*n*>, except that the operand <*n*> is implicit.
