It's not a secret anymore!
The moose likes Java in General and the fly likes Observing Java Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Observing Java Objects " Watch "Observing Java Objects " New topic

Observing Java Objects

bhaswar goswami

Joined: Jul 04, 2005
Posts: 14
When we try to change one Java objects that is being Observed by some
other java objcts(Observer ) then the following method is called

void update(Observable o, Object arg) - of the Observer objects

first agrument is the Observable Object that is changed , but i don't
know the purpose of the second argument .
I want o know when this second parameter is used and how ?


Bhaswar Goswami

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15091

It's an arbitrary object that you can pass to the observers. You decide yourself what you pass there - it can be any object you like. You can use it to give the observers some more info about what was changed in the observable. Just whatever is useful for what you are using the Observable / Observer class and interface for.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: Observing Java Objects
jQuery in Action, 3rd edition