--- tags: Setup --- # Lecture 7 Setup/Prep In lecture 7, we will turn to lists whose contents get modified on operations such as `addFirst`. We will first see how to use such lists as built into Java, then start the process of implementing such lists for ourselves. ## Prep Two things: - [download the starter code](https://brown-cs18-master.github.io/content/lectures/07listsimperative/lec07.zip), which is a variant on the functional list implementation that we wrote last week - look at the following sample code for using lists in Java (which is included in the starter code, in case you want to play with it). It shows how to create a new list, add items to it, and process a list with a construct called a for loop. ``` import java.util.LinkedList; public class JListExample { JListExample(){} public static void main(String[] args) { LinkedList<Integer> L = new LinkedList<Integer>(); L.addFirst(3); L.addFirst(5); // L is now the list [5, 3] // compute sum of items in L Integer total = 0; // a variable to hold the running sum for (Integer num : L) { total = total + num; } System.out.println(total); } ```