@@ -0,0 +1,1029 @@
+// --------------------- %E8%A2%AB%E8%A7%82%E5%AF%9F%E8%80%85%0A%0Apublic abstract class Subject %7B%0A    private Vector%3CObserver%3E obsVectors = new Vector%3CObserver%3E();%0A%0A    public void addObserver(Observer o) %7B%0A        obsVectors.add(o);%0A    %7D%0A%0A    public void delObserver(Observer o) %7B%0A        obsVectors.remove(o);%0A    %7D%0A%0A    public void notifyObservers() %7B%0A        for (Observer o : obsVectors) %7B%0A            o.update();%0A        %7D%0A    %7D%0A%0A    public abstract void doSomething();%0A%7D%0A%0A// --------------------- %E5%85%B7%E4%BD%93%E8%A2%AB%E8%A7%82%E5%AF%9F%E8%80%85%0A%0Apublic class ConcreteSubject extends Subject %7B%0A    public void doSomething() %7B%0A        System.out.println(%22ConcreteSubject doSomething...%22);%0A%0A        super.notifyObservers();%0A    %7D%0A%7D%0A%0A// --------------------- %E8%A7%82%E5%AF%9F%E8%80%85%0A%0Apublic class Observer %7B%0A    public void update() %7B%0A        System.out.println(%22Observer update...%22);%0A    %7D%0A%7D%0A%0A// --------------------- test code%0A%0Apublic static void main(String%5B%5D args) %7B%0A    Observer observer = new Observer();%0A    Subject subject = new ConcreteSubject();%0A%0A    subject.addObserver(observer);%0A    subject.doSomething();%0A%7D%0A

add observer pattern