Inner Classes

 public class DataSetTester3
{
   public static void main(String[] args)
   {
     
class RectangleMeasurer implements Measurer
      {
         . . .
      }
      Measurer m = new RectangleMeasurer();
      DataSet data = new DataSet(m);
      . . .
   }
}

Click here to see a sample.

Why would you use an inner class instead of a regular class?

   Answer: Inner classes are convenient for insignificant classes.
   Also, their methods can access variables and fields from the
   surrounding scope.


How many class files are produced when you compile the DataSetTester3 program?

   Answer: Four: one for the outer class, one for the inner class,
   and two for the
DataSet and Measurer classes.