How are Observer and Observable used?A list of observers is maintained by the objects of sub class of Observable class. The update() method is invoked when the Observable object is updated. The Observer interface is then implemented by the objects of Observable class.How are Observer and Observable used?The observable class represents an observable object. The object to be observed can be represented by sub-classing observable class. When there is a change in an observable instance, an application calling the Observable's notifyObservers method causes all of its observers to be notified of the change by a call to their update method.
|