wood burning stoves 2.0*
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
Author

Observing Java Objects

bhaswar goswami
Greenhorn

Joined: Jul 04, 2005
Posts: 14
Hi,
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 ?


Regards,

Bhaswar Goswami
SCJP 5.0 , SCDJWS


Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13875
    
  10

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 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Observing Java Objects
 
Similar Threads
Reacting to events outside of the class in which an event occurs
Variable Scope Problem
Frame
Observable and Observer - Send class object with notifyObservers() and use the object atthe Observer
Listen to changes to an integer variable to update JLabel