It’s appropriate to use an anonymous inner class if you are going to use the class only once. In the Factorial program in Figures, we use the
listenerobject twice, so that
listenerobject needed to have a name. However, we used that object’s class only once, to instantiate that one object. Therefore, that object’s class did not need to have a name, and we could have used an anonymous class to create our
listenerobject. For this exercise, modify the Factorial program to use an anonymous
ActionListenerclass instead of the named
Listenerclass. [Hint: The program is already set up to facilitate this change—it’s mostly cut-and-paste.]
Figure FactorialButton program–part A

Figure FactorialButton program–part B

We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.