import java.util.HashSet; import java.util.Iterator; import java.util.Set; public class SimpleObservableC implements SimpleObservableI { Set obsSet = new HashSet(); @Override public void add(SimpleObserverI o) { obsSet.add(o); o.update(); // as to display current value } @Override public void notifyAllObs() { Iterator i = obsSet.iterator(); while (i.hasNext()) { SimpleObserverI o = i.next(); o.update(); } } }