An example of OBServer mode

xiaoxiao2021-03-06  101

Observer mode Defines a pair of dependencies between objects. When the status of an object changes, all objects that depend on its object are notified and automatically updated. The implementation of the OBServer design pattern provided in JDK consists of Java.util.observable class and Java.util.observer interface. From the name, you can clearly see the roles that both play in OBSERVER design mode: OBServer is the observer role, OBSERVABLE is a Subject role. The following is a code example: package kellerdu.de;

Import java.util. *;

转载请注明原文地址:https://www.9cbs.com/read-96387.html

New Post(0)