Non-public top-level class vs static nested class

前端 未结 4 1072
情书的邮戳
情书的邮戳 2020-12-14 09:29

It seems to me that non-public top-level classes and static nested classes essentially perform the same tasks when creating a helper class.


A.java


<
4条回答
  •  轮回少年
    2020-12-14 09:35

    Nesting a class (statically in Java) sends a clear message of intent: the nested class AHelper is only relevant and usable to support A class. It has no meaning on its own, and this is immediately obvious.

提交回复
热议问题