Java Tutorial · Revision notes
Java Arrays
An array stores a fixed number of values of the same type in contiguous memory. This chapter covers one-dimensional arrays, 2D arrays, jagged arrays and the java.util.Arrays utility methods.
Quick revision
- Arrays: fixed size, same type, zero-based, objects on the heap
- Defaults: 0, false, null; length is a field
- 2D array is an array of arrays; m[i].length is the row length
- Jagged: new int[r][]; allocate each row
- Arrays.sort / binarySearch (sorted) / copyOf / fill / equals / toString
- a.equals(b) compares references; Arrays.equals compares content