First page Back Continue Last page Overview Graphics
Reasons for inner classes
More readable code
- all information for how to handle the event is located in one file
- for a novice this might be difficult to parse at first
Better encapsulation
- the inner class can be declared private and thus only accessible to its enclosing class
- e.g. the connection to a database server can be captured as an inner class limiting the classes that can directly connect to the database, enforcing the connection protocol
- one point of control!
Notes: