Lecture 7: Arrays and Lists

This lecture explores the main ways we have in Java of representing an ordered sequence of items. It starts with arrays, noting that they are somewhat similar to array storage allocated with malloc() in C. Two key differences are that arrays of primitive values are initialised properly, and attempts to go beyond the bounds of the array trigger an exception.

The lecture moves on to consider lists, highlighting their key advantage of being able to grow or shrink after creation. It discusses the two list types offered as standard by Java: ArrayList and LinkedList. It presents various examples of their use and explains why we would choose one type over the other.

Useful resources: