Ugly multiple inheritance in Java

Let’s say we have two classes:

Let’s imagine that the methods are really big and complex and for some horrid reason we want to inherit from both classes.

Here is the program we want:

Is this possible at all? Of course, this is Java, and horrible Java is also possible 🙂 Here you go:

We can also do it with even more nastiness:

But then we need this fantastic nonsense in the main class:

 


As always, should you be caught doing this, I will disavow any knowledge of your actions.

4 thoughts on “Ugly multiple inheritance in Java

  1. Reply

    armin walland

    default methods to the rescue 😀

    1. Reply

      tomas Post author

      Nasty 😀

      1. Reply

        armin walland

        and how!

        sorry i didn’t seem to get the formatting right ^^.

        1. Reply

          tomas Post author

          Yes, because you tried enclosing it in <code><code> (with no “/”!) instead of <pre></pre>. I have fixed it now 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Please answer this amazingly complicated math question to prove that you are not a spam bot: