The observer pattern is a pattern to enable the publisher/subscriber scenario between the classes of an application. In this pattern, there is an observable object that sends events to many observing objects registered to it for receiving events.
Let's take a look at the class diagram for the example implementation of the observer pattern:
So, our example is basically talking about a scenario in a user interface-based application where you have a KeyboardListener class that is listening to keyboard events and then there are some other classes that need to know about certain key events, for example, Caps Lock, Num Lock ...