// Using generic with an iterator

import java.util.ArrayList;
import java.util.Iterator;

...

/**
 * List of filename/count pairs. Definition of Pair class not shown.
 */
static final ArrayList<Pair> pairs = new ArrayList<Pair>();  // <--- note <Pair> on both sides of =

/**
 * debug dump of all the Pairs in the list
 */
static void dumpPairs()
   {
   Iterator<Pair> iter = pairs.iterator(); // <--- note <Pair>
   while ( iter.hasNext() )
      {
      Pair aPair = iter.next();  // <--- note lack of cast
      out.println( aPair.filename + " " + aPair.count );
      } // end while
   }

/**
 * or better still, use the for each loop
 */
static void dumpPairs()
   {
   Iterator<Pair> iter = pairs.iterator(); // <--- note <Pair>
   for ( Pair aPair : iter )
      {
      out.println( aPair.filename + " " + aPair.count );
      } // end for
   }