inner class extending

独自空忆成欢 提交于 2019-12-04 00:16:26

According to this page, you have the right way figured out to extend inner classes. A few tips about it can be found here, in the middle of the article (search for "extend").

If that doesn't work (I don't think it will), the following should:

public class C extends A{
  protected class D extends A.B{
  }
}

Well, it will, but what if you have another class named B outside of A?

Edit: nope, it makes no difference. Even if there is another class named B, it will still take A.B. So your syntax is correct.

You are allowed to do that but don't expect your C class to use D class instead of A's inner B class automatically.

Each inner class can independently inherit from an implementation. Thus, the inner class is not limited by whether the outer class is already inheriting from an implementation.

--- Thinking In Java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!