How to make an outer class inherited from an inner class?

前端 未结 7 1153
执笔经年
执笔经年 2020-12-19 04:08

How can I make something like this work:

class Outer {
  int some_member;

  abstract class InnerBase {
    abstract void method();
  }
}

class OuterExtends         


        
7条回答
  •  天命终不由人
    2020-12-19 04:49

    The outer class can extend the inner class iff the inner class is compiled to ".class".

    Now, every time you compile the outer class it encounters the "extends innerclass" which is

    not yet compiled and the compiler will throw a NoClassDefException or ClassNotFoundException.

    Isn't it ? So you will never get that inner class compiled. If you can overcome this problem

    then you can also extend the inner class :) .

提交回复
热议问题