Lecture 24 Objectives [Dec 08]prev next

ART MOMENT: .
 
Almshouse Man in a Top Hat
Artist: Vincent van Gogh (1853-1890)
Date: 1882
 

With student id, museum tickets cost only $8


At the end of today's class you should

HAVE READ:

KNOW:

BE ABLE TO:

DAILY QUESTION:


Sample Exam question(s)

1. You are given an ArrayList known to contain String values. Write a method using an Iterator that returns the number of Strings in the ArrayList that are four characters in length.

/**
 * Take in an ArrayList of String objects and return the number of
 * Strings that are four characters in length.
 */
public static int count(ArrayList al) {

   // Fill in .... 

}

2. Convert the following code from a while loop into a for loop

Iterator it = al.iterator();
while (it.hasNext()) {
   String s = (String) it.next();
   System.out.println (s);
}