Array
In short: An array is an ordered row of values of the same type that are addressed by a number (the index). Counting almost always starts at 0.
In more detail: In memory the elements lie directly one after another. Access by index is therefore very fast (constant time). In many languages (Java, C) the length is fixed after creation.
In detail
int[] numbers = {4, 8, 15};
System.out.println(numbers[0]); // 4
System.out.println(numbers.length); // 3
numbers[2] = 16;- Access:
a[i], valid from 0 to length−1. Otherwise ArrayIndexOutOfBoundsException. - Iterating: for loop or enhanced for loop.
- Multidimensional: array of arrays, see Multidimensional arrays.
- Dynamic: growing lists (ArrayList, Python list, JS array) see Dynamic array.
- Sorting:
Arrays.sort(a), ascending or descending, see Ascending and descending.