java traits or mixins pattern?

前端 未结 8 2217
小蘑菇
小蘑菇 2020-12-16 14:02

Is there a way to emulate mixins or traits in java? basically, I need a way to do multiple inheritance so I can add common business logic to several classes

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-16 14:14

    As of Java-8, default interface methods were added. This, together with multiple inheritance of interfaces in Java should allow some sort of mixin. Clearly the interfaces have to operate independently. So, there will be significant limitations.

提交回复
热议问题