Inner Classes
Trivial class can be defined inside a method
public class DataSetTester3
{
public static void main(String[] args)
{
class RectangleMeasurer implements Measurer
{
. . .
}
Measurer m = new RectangleMeasurer();
DataSet data = new DataSet(m);
. . .
}
}
If inner class is defined inside an enclosing class, but outside its methods, it is available to all methods of enclosing class
Compiler turns
an inner class into a regular class file:
DataSetTester$1$RectangleMeasurer.class

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.