Inner Classes
| |||
In Java 1.1 and later, you can define an inner
class. This is a class whose body is defined inside another class,
referred to as the top-level class. For example
Inner classes may also contain methods. They may not
contain static members.
Inner classes in a class scope can be public, private, protected, final, abstract. Inner classes can also be used inside methods, loops,
and other blocks of code surrounded by braces ( The inner class has access to all the methods and fields of the top-level class, even the private ones. The inner class's short name may not be used outside its
scope. If you absolutely must use it, you can use the fully qualified name
instead. (For example, Inner classes are most useful for the adapter classes required by 1.1 AWT and JavaBeans event handling protocols. They allow you to implement callbacks. In most other languages this would bo done with function pointers. | |||
|