简体   繁体   English

内部类和静态上下文

[英]Inner class and static context

根据JLS§8.1.3,为什么Java不允许在Inner类中使用静态上下文?

Inner class will belong to instance of its Outer class. 内部类将属于其外部类的实例。

If Java accept static non final variables in inner class, then there may be different values for that static variables for different instances of outer class. 如果Java在内部类中接受静态非最终变量,那么对于外部类的不同实例,该静态变量可能会有不同的值。

Its totally against the static context definition. 它完全违反静态上下文定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM