title: Is there a way for an instance of a Java Outer Class to call all its instances of a Java Inner Class?
body: <p>With the following code:</p>
  
  <pre><code>public class Outer {
      final int foo;
  
      public Outer(int foo) {
          this.foo = foo;
      }
  
      public Inner createInnerInstance(int bar) {
          return new Inner(bar);
      }
  
      public int getBarSum() {
          // TODO: implement
      }
  
      public class Inner {
          final int bar;
  
          public Inner(int bar) {
              this.bar = bar;
          }
  
          public int getBar() {
              return bar;
          }
  
          public int getFooPlusBar() {
              return foo + bar;
          }
      }
  }
  </code></pre>
  
  <p>I would like to add a method to <code>Outer</code> which calls a method on every <code>Inner</code>.</p>
  
  <p>One way of doing this is for <code>Outer</code> to keep a <code>List</code> of <code>Inner</code> instances, which <code>getInnerInstance</code> appends to.  The problem with this is that I don't want the list's reference to inner instances to keep them from being garbage collected.  Would some form of weakly-linked List be possible in Java?</p>
  
  <p>Are there any different approaches?</p>
  
  <p>Note: I'm only looking for the <code>Inner</code>s which share the particular instance of <code>Outer</code>. </p>