rparamal
asked on
Java Observer
I am having difficulties using Java Observer and Observable.
This is how I tried, but it didn't work. Please email
me with the mistakes I am making.
class x_class extends Observable
{
LinkedList TL;
--
--
--
notifyObserver(TL)
--
--
--
}
class y_class extends Object implements Observer
{
--
--
--
void update(x_class x, LinkedList L)
{
--
--
--
}
in the init function in the applet
void init()
{
y_class y = new y_class;
x_class x = new x_class;
x.addObserver(y);
}
I redd the answer urgently.
Thank you,
This is how I tried, but it didn't work. Please email
me with the mistakes I am making.
class x_class extends Observable
{
LinkedList TL;
--
--
--
notifyObserver(TL)
--
--
--
}
class y_class extends Object implements Observer
{
--
--
--
void update(x_class x, LinkedList L)
{
--
--
--
}
in the init function in the applet
void init()
{
y_class y = new y_class;
x_class x = new x_class;
x.addObserver(y);
}
I redd the answer urgently.
Thank you,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The answer given is correct. 'setChanged' must be called before 'notifyObserver'. Note: 'notifyObserver' will automatically clear the changed state of the Observable class.