ArrayList Loop Patterns


Review: The Foreach Loop

    // Construct a list (initially empty) that could hold fish.
    // Then construct many new fish and add them to the list.
    .
    .
    .

    // Move each fish forward, without changing direction.
    for ( AquaFish f : fishList )
    {
        f.moveForward();
    }

Alyce Brady, Kalamazoo College