---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 21 Edition"
java_version: 21
chapter: "Chapter 10. Arrays"
section: "10"
heading: "Chapter 10. Arrays"
source: https://docs.oracle.com/javase/specs/jls/se21/html/jls-10.html
id: "10"
url: https://jvm.obfuscated.software/jls/se21/10.html
raw: https://jvm.obfuscated.software/jls/se21/10.md
---

# Chapter 10. Arrays

In the Java programming language, *arrays* are objects ([§4.3.1](4.3.1.md)), are dynamically created, and may be assigned to variables of type `Object` ([§4.3.2](4.3.2.md)). All methods of class `Object` may be invoked on an array.

An array object contains a number of variables. The number of variables may be zero, in which case the array is said to be *empty*. The variables contained in an array have no names; instead they are referenced by array access expressions that use non-negative integer index values. These variables are called the *components* of the array. If an array has *n* components, we say *n* is the length of the array; the components of the array are referenced using integer indices from 0 to *n* - 1, inclusive.

All the components of an array have the same type, called the *component type* of the array. If the component type of an array is T, then the type of the array itself is written T`[]`.

The component type of an array may itself be an array type. The components of such an array may contain references to subarrays. If, starting from any array type, one considers its component type, and then (if that is also an array type) the component type of that type, and so on, eventually one must reach a component type that is not an array type; this is called the *element type* of the original array, and the components at this level of the data structure are called the *elements* of the original array.

There are some situations in which an element of an array can be an array: if the element type is `Object` or `Cloneable` or `java.io.Serializable`, then some or all of the elements may be arrays, because any array object can be assigned to any variable of these types.

**Sections:**

- [10.1. Array Types](10.1.md)
- [10.2. Array Variables](10.2.md)
- [10.3. Array Creation](10.3.md)
- [10.4. Array Access](10.4.md)
- [10.5. Array Store Exception](10.5.md)
- [10.6. Array Initializers](10.6.md)
- [10.7. Array Members](10.7.md)
- [10.8. Class Objects for Arrays](10.8.md)
- [10.9. An Array of Characters Is Not a String](10.9.md)
