Java Arrays: Difference between revisions
Line 11: | Line 11: | ||
Array instances are objects. They are dynamically created, they can be assigned to a variable of type <code>Object</code> and all methods of class <code>Object</code> may be invoked on an array. | Array instances are objects. They are dynamically created, they can be assigned to a variable of type <code>Object</code> and all methods of class <code>Object</code> may be invoked on an array. | ||
An array instance contains a number of variables, called '''array components''' that have no names, and can be referenced instead by array access expressions that use non-negative integer indices. | An array instance contains a number of variables, called '''array components''' that have no names, and can be referenced instead by array access expressions that use non-negative integer indices. The number of components 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. | 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. |
Revision as of 00:39, 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.
An array instance contains a number of variables, called array components that have no names, and can be referenced instead by array access expressions that use non-negative integer indices. The number of components 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.
array element
Array Types
Array Variables
Array Creation
Array Creation with an Expression
Array Creation with an Array Initializer
Array Access
Multidimensional Arrays
A multidimensional array is an array of multidimensional arrays.