31-ArrayList

31-ArrayList - Mehran Sahami CS 106A Handout #31 October...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Mehran Sahami Handout #31 CS 106A October 31, 2007 ArrayLists Reference for Hangman Based on a handout by Patrick Young This handout gives you a quick reference for some of the concepts related to ArrayLists that may be useful to you for implementing Part III of the Hangman assignment. ArrayLists You can think of an ArrayList as being a special object which is used to store a list of other objects. In your case, you’ll be using an ArrayList to store the list of String s which can be chosen as words for Hangman. Using ArrayLists ArrayLists are defined in the java.util package. To use ArrayLists, you’ll need to import the package: import java.util.*; Declaring an ArrayList variable ArrayLists can store a variety of different types of information—for example, you can create an ArrayList of GOval s, an ArrayList of GRect s, or in the case of Hangman an ArrayList of String s. When declaring a variable of type ArrayList, you’ll need to specify what type of data is stored in the ArrayList using a special angular bracket notation. Your declaration will
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

31-ArrayList - Mehran Sahami CS 106A Handout #31 October...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online