扩展多个类 [英] Extending multiple classes

查看:90
本文介绍了扩展多个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道Java不支持多重继承,因为不允许扩展多个类。我只是想知道我的问题是否有解决方法。

I know Java doesn't support multiple inheritance by not allowing to extend more than one class. I just want to know if there is a workaround for my issue.

我有一个名为 CustomAction 的类需要扩展两个抽象类, BaseAction QuoteBaseAction 。我不能改变任何这些抽象类,并将其他类扩展。

I've a class named CustomAction which needs to extend two abstract classes, BaseAction and QuoteBaseAction. I can't change any of these abstract classes and make one extend other.

这些抽象类有我需要使用的方法实现。我也无法创建界面,因为界面只能扩展另一个界面。

These abstract classes have method implementations which I need to make use of. I can't create an interface also since an interface can extend only another interface.

任何想法?

推荐答案

这里你去...

public class CustomAction extends BaseAction {
  class Inner extends QuoteBaseAction {

  }
}

这篇关于扩展多个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆