//ArrayList class is in the //java.util package import java.util.*; class ItemsListing { private String item; // Constructor with parameters. When each object // is instantiated, or created, arguments must be // provided so the object contains the required // data. public ItemsListing (String item) { // The keyword this is necessary to prevent confusion // over which object you are referring to when // you instantiate multiple objects. this.item = item; } // Method to convert the objects to Strings. public String toString() { String s = "Item: " + item; return s; } } public class ArrayListItems { public static void main(String []args) { // Creates an ArrayList to store each object, and // adds each object with the add method and dot operator // as well as with the arguments for each object. ArrayList items = new ArrayList(); items.add(new ItemsListing("Snorkel")); items.add(new ItemsListing("Diving Mask")); items.add(new ItemsListing("6.5 mm Wet Suit")); // The ArrayList is then passed to an Iterator Iterator iterateItems = items.iterator(); // while loops through each element of the ArrayList // and prints the results while (iterateItems.hasNext()) { System.out.println(iterateItems.next()); } } }