Its appropriate to use an anonymous inner class if you are going to use the class only
Question:
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 17.8a and 17.8b, we use the listener object twice, so that listener object 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 listener object. For this exercise, modify the Factorial program to use an anonymous ActionListener class instead of the named Listener class.
Figures 17.8a:
Figures 17.8b:
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean
Question Posted: