当前位置: 技术问答>java相关
Java中,Inner class可不可以使用final修饰符?
来源: 互联网 发布时间:2015-04-21
本文导语: help | Surely. When you do so, it only means that you don't want any other classes to inherit from it. | 首先你要清楚,Inner Class分好几种 例如成员类,是可以加任何修饰符的 但是其...
help
|
Surely. When you do so, it only means that you don't want any other
classes to inherit from it.
classes to inherit from it.
|
首先你要清楚,Inner Class分好几种
例如成员类,是可以加任何修饰符的
但是其他的就不一样了,具体的嘛,偶忘记了,要查查,呵呵
例如成员类,是可以加任何修饰符的
但是其他的就不一样了,具体的嘛,偶忘记了,要查查,呵呵
|
Any class (if it has a name) can be declared final or abstract, and any accessible non-final named class or interface can serve as a supertype. A compiler may also change a class to be final if it can determine that it has no subclasses, and that there is no way for subclasses to be added later. This is possible when a private or block-local class has no subclasses in its scope.
|
The keyword "final" in Java is used in different ways depending on the context. We can have final
methods, final classes, final data members, final local variables and final parameters. A final class
implicitely has all the methods as final, but not necessarily the data members. A final class may
not be extended, neither may a final method be overridden.
methods, final classes, final data members, final local variables and final parameters. A final class
implicitely has all the methods as final, but not necessarily the data members. A final class may
not be extended, neither may a final method be overridden.