title: addObserver() method, of observer pattern and object variable lifecycle/scope, Java
body: <p>when I use the method .addObserver() for example:</p>
  
  <pre><code>  class ExampleOne implements Observer {
  
    class ExampleTwo extends Observable {
  
  
    ExampleOne one = new ExampleOne();
  
    ExampleTwo two = new ExampleTwo();
  
    two.addObserver(one)
  </code></pre>
  
  <p>in this case, is the connection between instance objects "two" and "one" or the class.class like a static situation,  it looks to me like instance, but not sure, if this is a connection between observer and the observed then what happens if either "one" or "two" is garbage collected or goes out of scope?   does that destroy the observer setup.</p>
  
  <p>example of this is when a server receives a String message from the client,  and the observer is used to notify when a new text message has arrived.  if one of the instance variables goes out of scope and is garbage collected then there will be no more notification when messages arrive because the system will be broken.  is this correct?</p>