Learn to declare, initialize, and manipulate fixed-size arrays.
An array is a fundamental data structure in Java that stores a fixed-size, sequential collection of elements of the same type. Think of it as a container that can hold, for example, 10 integers or 5 strings. The size of an array is established when it is created and cannot be changed afterward. To declare an array, you specify the type of its elements followed by square brackets, for example, `int[] numbers;`. To create the array and allocate memory for it, you use the `new` keyword and specify the size, like `numbers = new int[10];`. This creates an array that can hold 10 integers. The elements in the array are accessed via an index, which is a zero-based integer. This means the first element is at index 0, the second at index 1, and so on, up to the last element at index `length - 1`. You can access or modify an element by using its index, for example, `numbers[0] = 5;`. Java provides a `length` property to get the size of an array. The most common way to process all elements in an array is by using a `for` loop, iterating from index 0 to `array.length - 1`. Java also provides an enhanced `for-each` loop, which offers a more concise syntax for iterating over array elements when you don't need the index. Arrays can be of any data type, including primitive types and object references. You can also have multi-dimensional arrays, which are essentially arrays of arrays, useful for representing grids or matrices.