SYSC 2004 Lecture Notes - Lecture 6: Iter, Iterator, Java Collections Framework

65 views3 pages

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));

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents