SYSC 2004 Lecture Notes - Lecture 6: Iter, Iterator, Java Collections Framework
Document Summary
Lecture 06: grouping objects and arrays/ array lists. Chapter 4, grouping objects, chapter 5. 4, foreach loops, and chapter 7, fixed-size collections -- Linked list: allows for easier adding to the list. Arraylist - a class from the java collections framework defined in package java. util stores a collection of objects in a list (actually, it stores references to the objects) To make the arraylist class available: - import java. util. arraylist; tells the compiler to make class arraylist from package java. util available import statements must be placed before the class definition. Arraylist has a method called add() that stores an object at the end of the list: We don"t need variable player; instead, we can create an anonymous player object and pass that object to add(): players. add(new player(name, board)); Monopolygame provides a method to add players to the game public void addplayer(string name) players. add(new player(name, board));