Java Arrays: Difference between revisions
Line 30: | Line 30: | ||
=Multidimensional Arrays= | =Multidimensional Arrays= | ||
The components of a multidimensional array are themselves of the same [[#Array_Type|array type]], and they contain references to '''subarrays'''. | |||
A multidimensional array is an array of multidimensional arrays. | A multidimensional array is an array of multidimensional arrays. | ||
==Bidimensional Arrays== | ==Bidimensional Arrays== | ||
==Tridimensional Arrays== | ==Tridimensional Arrays== |
Revision as of 01:09, 2 November 2021
External
- https://docs.oracle.com/javase/specs/jls/se8/html/jls-10.html
- https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
Internal
Overview
Array instances are objects. They are dynamically created, they can be assigned to a variable of type Object
and all methods of class Object
may be invoked on an array. More details about array creation are available in the Array Creation section below.
An array instance contains a number of variables, called array components. The array components have no names, and they are referenced by array access expressions that use non-negative integer indices. The number of components of an array is fixed, once the array instance is created, the number of components cannot change. If the number of components of an array is zero, the array is said to be empty. If the array has n components, then it is said that the array has the length n. In this case, its components are referenced with zero-based indices from 0 to n-1. More details about accessing array components and elements are available in the Array Access section below.
The components can be of primitive types or reference types. All components of an array have the same type, called the component type of the array.
Multidimensional arrays are a special case where all the components have the same array type, which is in itself a reference type.
array element
Array Types
An array type is a kind of a reference type. If the component type of an array is T
, then the type of the array itself is written T[]
.
Array Variables
Array Creation
Array Creation with an Expression
Array Creation with an Array Initializer
Array Access
Multidimensional Arrays
The components of a multidimensional array are themselves of the same array type, and they contain references to subarrays.
A multidimensional array is an array of multidimensional arrays.