public, package (default),
    protected, or private access. 
    
public class NaryTree {
  // blah blah blah
  private class
  NaryTreeNode {
    // blah blah blah
    }
  }
NaryTree can access NaryTreeNode, but no other class —
  including NaryTree ancestors — can.
  
two classes should be tied together and made available as a unit.
public class AdmissionQueue {
  // blah blah blah
  public class
  Ticket { ... }
  public Ticket enqueue(Object o) { ... }
  public void cancel(Ticket t) { ... }
  }
AdmissionQueue.Ticket.
  
public interface Iterator { boolean hasNext(); Object next(); void remove(); // optional }
import java.util.Iterator; void moo() { NaryTree root = new NaryTree(10) // blah blah blah finalIteratori = root.preorderIterator() while (i.hasNext()) final Object o = i.next() // blah blah blah }
TreeIterator class implementing the
  Iterator interface.
  TreeIterator relative to NaryTree?
  TreeIterator class details aren’t generally
  interesting.
    
NaryTree, make
  TreeIterator an inner class.
  
TreeIterator implemented?
    
TreeIterator relative to NaryTree?
  
public class NaryTree {
  private class NaryTreeIterator
  implements Iterator {
    NaryTreeIterator(...) {...}
    // blah blah blah
    }
  public Iterator prefixIterator() {
    final NaryTreeIterator i = 
      new NaryTreeIterator(...);
    // blah blah blah
    return i;
    }
  }
final NaryTree t = new NaryTree(10) // blah blah blah finalIteratori = t.prefixIterator()

.this in the
    inner class.
    this, it’s redundant.
    
class OuterClass {
  String talk = "moo";
  void say(String what) {
    System.out.println(what);
    }
  private class InnerClass {
    void go() {
      say(talk);
      OuterClass.this.say(
        OuterClass.this.talk);
      }
    }
  }

NaryTreeNode should be a static inner class.
public class NaryTree {
  private static class 
  NaryTreeNode { ... }
  }
new operator creates class instances.
NaryTree root = new NaryTree(10);
Comparable c = new Comparable();
class t {
  int moo() {
    Comparable c = new Comparable() {
      public int compareTo(Object o) {
        return -1;
        }
      };
    return c.compareTo(this);
    }
  }
new classConstructorCall{classFeatureDefinitions...}
abstract class t {
  t(int i, String s) { }
  abstract void moo();
  }
class u {
  void moo() {
    t t1 = new t(1, "hello") {
          String label = "hello";
          void moo() { }
          void baa() { }
          };
    }
  }