Wednesday, March 22, 2017

Java | The power of Anonymous Class

Overloading a method in an Anonymous class

Client Class
Client Controller JavaFX
As you can see on the pictures above, display method is defined and called in the client class. If we want that any process from the display method to be done in a different class, we can use an anonymous class. The idea is simple. you create an instance of a class that immediately invoked itself and overload all the methods which are defined and called in that class to be done in the target class.

No comments:

Post a Comment