title: A class inheriting methods from two sources
body: <p>It's hard to explain, but it's simple to show a snippet of Ruby code:</p>
  
  <p>Have two modules that implement methods:</p>
  
  <pre><code>module Foo
      def one
          print "ONE!"
      end
  end
  
  module Bar
      def two
          print "TWO!"
      end
  end
  </code></pre>
  
  <p>Have a class that includes them:</p>
  
  <pre><code>class Test
      include Foo
      include Bar
  end
  </code></pre>
  
  <p>Now your class <code>Test</code> can call those two methods.</p>
  
  <hr>
  
  <p>As far as I'm aware, there isn't something like this in Java. Close concepts would be:</p>
  
  <p><strong>Multiple inheritance</strong></p>
  
  <p>Which is not supported by Java.</p>
  
  <p><strong>Interfaces</strong></p>
  
  <p>They're method contracts - there is no implementation. Your class <code>Test</code> would need to implement the methods itself, and that's what I want to avoid. Simply for the sake of not writing the same code twice (I have several other classes, some of them may want to implement those methods too).</p>
  
  <p><strong>Abstract classes</strong></p>
  
  <p>I'd still need to inherit from two classes at the same time.</p>
  
  <hr>
  
  <p>So what is the recommended solution here?</p>