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:

/********************************** * FactorialButton.java * Dean & Dean * * When user clicks button or

Figures 17.8b:

//**************************************************** // Inner class for event handling. private class

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: