posted 23 years ago
An inner class defined inside a method is a local class. Its scope is limited to the inside of the method only. However, if it implements or extends an interface or class which is defined outside the method, then you can pass an instance of your local class into the outside world. For example, you can create an anonymous (local) class which implements ActionListener, and pass it to some other object using the addActionListner() method.
The main reasons to use local classes are: if the class will only ever be used in a small area, then it makes sense to define it as close to that area as possible. And, local classes can access local variables in the same method, provided they are final - something which non-local classes cannot do. So you may occasionally find this useful.
"I'm not back." - Bill Harding, Twister