Sometimes it's necessary to issue requests to objects without knowing anything about the operation being requested or the receiver of the request.
Commands are the object-oriented equivalent of callbacks and encapsulate the callback function.
This Java Tip demonstrates how to implement the Command pattern in Java. A Command pattern is an object behavioral pattern that allows us to achieve complete decoupling between the sender and the receiver. The term request here refers to the command that is to be executed. The Command pattern also allows us to vary when and how a request is fulfilled. Therefore, a Command pattern provides us flexibility as well as extensibility.