Link to home
Start Free TrialLog in
Avatar of rparamal
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,
ASKER CERTIFIED SOLUTION
Avatar of koehn
koehn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gerry99
gerry99

The answer given is correct.  'setChanged' must be called before 'notifyObserver'.  Note: 'notifyObserver' will automatically clear the changed state of the Observable class.