Java Arrays
An array is a fixed-size row of boxes, all the same type. Create: int[] a = new int[5]; or int[] a = {10, 20, 30}; Indexes start at 0. First item is a[0]. Length is a.length — a field, not a method.
Loop with for or for-each. Size cannot grow later. If you need a growing list, use ArrayList. Last valid index is a.length - 1. a[a.length] throws ArrayIndexOutOfBoundsException.
Interview line — fixed size, same type, index from 0, length field.
Let's take this on the board with one tiny Main class — no extra files. Java Arrays — output: 10 then 20 then 30. Index 0, 1, 2. a[3] would throw ArrayIndexOutOfBoundsException. Start from main, go line by line, and stop at each print. That output is the proof for Arrays.
index → 0 1 2
array → [10, 20, 30]
↑ ↑
first length-1Last index is length - 1. Contrast with ArrayList.