Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Inner classes will show up throughout the exam, in any topic, and these are some of the exam’s hardest questions. You should be comfortable with the sometimes bizarre syntax, and know how to spot legal and illegal inner class definitions.
We looked first at “regular” inner classes, where one class is a member of another. You learned that coding an inner class means putting the class definition of the inner class inside the curly braces of the enclosing (outer) class, but outside of any method or other code block. You learned that an inner class instance shares a special relationship with a specific instance of the outer class, and that this special relationship lets the inner class access all members of the outer class, including those marked private. You learned that to instantiate an inner class, you must have a reference to an instance of the outer class.