Lesson 4: Arrays & Multidimensional Arrays
05 Jul 2026 1 min Swarnil Singhai
Arrays give O(1) index access and a fixed size — ideal when the shape of data is known upfront, like a seating chart.
Real-time example
A cinema booking system models seats as a 2D array: rows x columns, so checking seat availability is a single lookup.
boolean[][] seats = new boolean[10][20]; // 10 rows, 20 seats/row
seats[3][14] = true; // row 4, seat 15 booked
int free = 0;
for (boolean[] row : seats)
for (boolean seat : row)
if (!seat) free++;
System.out.println("Free seats: " + free);
What's happening
A 2D array is really an array of arrays in Java — seats[3] alone gives you the whole row 4 array.
Arrays are the right tool when size is fixed and access pattern is by index — use collections when it grows or shrinks.
Advertisement