Observable in Java

前端 未结 9 1894
别那么骄傲
别那么骄傲 2020-12-14 19:30

I\'m trying to understand the Observer and the Observable.

Here\'s an example that I\'m trying to figure out:

public class IntegerDataBag extends Obs         


        
9条回答
  •  旧时难觅i
    2020-12-14 19:52

    The update() method is called by the Observable. This method is called by calling notifyObservers(), which itterates trough all Observers and calls update on them. This informs the Observer that the object they are watching has been changed and a certain action can be performed. The args object is whatever you want it to be, it can be null aswell but it can be used to inform the observers what type of update just took place.

提交回复
热议问题