This section will introduce the notion of nested classes, i.e classes that are defined as part of of an enclosing class. We have seen nesting before: methods are nested within the class where the methods are declared. The new thing here is that classes are nested within a class. The general notion of nesting, however, is not new. Algol 60 had e.g. procedures as part of procedures, and many languages may have nested blocks of program text; nesting is therefore also known as block structure. SIMULA introduced nested classes.
In the next pages we illustrate nested classes by three examples: (1) the first example is representing a context-free grammar, (2) the next example is in the domain of flights and routes of flights, and (3) the final example is in the domain of text processing.