Skip to content

Instantly share code, notes, and snippets.

@anjanashankar9
Last active Dec 13, 2020
Embed
What would you like to do?
Observer Pattern - Main
public class Main {
public static void main(String[] args) {
ConcreteObserver1 observer1 = new ConcreteObserver1();
ConcreteObserver2 observer2 = new ConcreteObserver2();
ConcreteSubject1 subject1 = new ConcreteSubject1();
subject1.register(observer1);
subject1.register(observer2);
subject1.setMessage("Status change 1");
subject1.unregister(observer1);
subject1.setMessage("Status change 2");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment