Lesson content
Read, practise, then check your understanding
An array is a fixed-length object with zero-based indices. Its element type is fixed, primitive elements receive zero-like defaults, and reference elements begin as null. Invalid indices throw ArrayIndexOutOfBoundsException.
Shapes and utilities
int[] scores = {72, 84, 91};
int[][] matrix = {
{1, 2, 3},
{4, 5, 6}
};
int[][] ragged = new int[3][];
ragged[0] = new int[2];
Arrays.sort(scores);
int position = Arrays.binarySearch(scores, 84);
Java multidimensional arrays are arrays of arrays, so rows can differ in length and are separate objects. Array covariance permits Number[] values = new Integer[2], but an invalid store fails at runtime; generic collections provide stronger compile-time safety. Use Arrays.copyOf, fill, equals, deepEquals, and stream rather than rewriting standard operations. Choose ArrayList when size must change and clone nested arrays explicitly when a deep copy is required.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.