Why is Java prohibiting inheritance of inner interfaces?

前端 未结 3 1959
醉梦人生
醉梦人生 2021-02-18 21:21

I.e. why is the following \"cyclic dependency\" not possible?

public class Something implements Behavior {
    public interface Behavior {
        // ...
    }
}         


        
3条回答
  •  感动是毒
    2021-02-18 22:01

    Imagine you are the compiler.

    We are saying you to create a class Something. This class implements Behavior... But Behavior does not exist yet because Something is not already registered...

    Do you understand the problem ?

    See class as box which contains things. Behavior is contained in the box Something. But Something does not exist.

提交回复
热议问题