title: Creating an implementing class that reuses objects of other implementations of the same interface
body: <p>I want to create a class that does not implement any method of an interface, but extends any implementation of A with it's own methods.</p>
  
  <p>Let's assume we have the following:</p>
  
  <pre><code>public interface A {
      public void a();
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class B implements A {
      @override
      public void a() {
          System.out.println("a");
      }
  }
  </code></pre>
  
  <p>I now want to create a class <code>C</code> that also <code>implements A</code> and takes another random implementation of <code>A</code>:</p>
  
  <pre><code> public class C implements A {
          public C(A a) {
              //what do I need to do with a here?
          }
          public void c() {
              System.out.println("c");
          }
      }
  </code></pre>
  
  <p>Now if I have the following:</p>
  
  <pre><code>A b = new B();
  A c = new C(b);
  c.a();
  </code></pre>
  
  <p>The output should be "a".</p>
  
  <p>I can't just</p>
  
  <pre><code>public class C extends B {
  ...
  </code></pre>
  
  <p>as C is supposed to be able to work with any implementation of A, not just B.</p>
  
  <p>I also can't</p>
  
  <pre><code>  public class C implements A {
          private a;
          public C(A a) {
              this.a = a;
          }
          @override
          public void a() {
              a.a();
          }
          public void c() {
              System.out.println("c");
          }
      }
  </code></pre>
  
  <p>since that would mean that I have to redirect every single interface method and rewrite C whenever something changes with A.</p>
  
  <p>Is there any way to handle that problem in Java?</p>
  
  <p>For another example, replace A: List; B: ArrayList; C: FooList; a(): size()</p>