This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Observing Java Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply 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
Bartender

Joined: Aug 16, 2005
Posts: 12929
    
    3

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
Listen to changes to an integer variable to update JLabel
Frame
Variable Scope Problem
Observable and Observer - Send class object with notifyObservers() and use the object atthe Observer
Reacting to events outside of the class in which an event occurs