A class can be marked by the "private" access specifier only
if its a nested member of another class.
Top level classes cannot be marked as "private". Hence you
can have private classes in a java file but they must be
nested inside another class.
private class
本文解释了在Java中使用private访问限定符的规则。顶级类不能被声明为私有的,但可以在其他类内部定义私有类。这一特性允许更精细的封装控制。

被折叠的 条评论
为什么被折叠?



