Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • won't work. Thing1Ext should extend Thing1 and not the BaseThing, there are some common specifics here. Commented May 1, 2016 at 9:56
  • Got it. In that case, the only solution you have is to use composition: class ThingExt extends AbstractBaseThingExt with AbstractBaseThingExt being your abstract class that holds common fields. Then ThingExt should take a BaseThing in the constructor. Editing my answer... Commented May 1, 2016 at 10:14
  • @Flot2011, your own proposed solution does just that tho. ThingXExt extends ThingX which extends BaseThing. You can't remove the inheritance of BaseThing further down the hierarchy. Commented May 1, 2016 at 10:25
  • @ChiefTwoPencils: Yes, but I can use a code specific to Thing1 in Thing1Ext without typecasting it all around. Commented May 1, 2016 at 10:37