Code example for Vector

Methods: contains, removeElement

0
            listeners.addElement(observer);
        } 
    } 
     
    public void removeObserver(Observer observer) {
        if (listeners.contains(observer)) {
            listeners.removeElement(observer);
        }  
    } 
     
    public void notifyObservers() { 
        int size = listeners.size();
        for (int i = 0; i < size; i++) {
            Observer observer = (Observer) listeners.elementAt(i);
            observer.update(this);
        } 
    } 
 
    public void notifyObservers(Object data) {
        int size = listeners.size();
        for (int i = 0; i < size; i++) {