FileDocCategorySizeDatePackage
CustomObjectTester.javaAPI DocExample955Mon May 24 15:27:56 BST 2004com.oreilly.tiger.ch07

CustomObjectTester

public class CustomObjectTester extends Object

Fields Summary
private GuitarManufacturerList
manufacturers
A custom object that extends List
Constructors Summary
public CustomObjectTester()

    this.manufacturers = new GuitarManufacturerList();
  
Methods Summary
public static voidmain(java.lang.String[] args)

    try {
      CustomObjectTester tester = new CustomObjectTester();

      tester.testListExtension(System.out);
    } catch (Exception e) {
      e.printStackTrace();
    }
  
public voidtestListExtension(java.io.PrintStream out)

Test iterating over an object that extends List

    // Add some items for good measure
    manufacturers.add("Epiphone Guitars");
    manufacturers.add("Gibson Guitars");

    // Iterate with for/in
    for (String manufacturer : manufacturers) {
      out.println(manufacturer);
    }