本文介绍了是否需要将私有嵌套类的内部声明为私有?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 如果删除 private ,则有 public 内部类和 private 内部类:更多为程序员考虑

  • 如果 private > ,所有能访问外部文件的人都可以访问内部类的私有数据

    • Making the methods of an inner classes private serves as documentation: the outer class shouldn't use these methods
    • If private is kept, it makes it much easier to promote an inner class to its own file
    • If private is dropped, there are two styles for public inner classes and private inner classes: more for the programmer to think about
    • If private is dropped and the inner class was made public, suddenly everyone who has access to the outer file has access to the inner class's private data

    鉴于上述风格,我认为防止丢弃的情况更强。

    Given the above style, I think the case against dropping is stronger.

    这篇关于是否需要将私有嵌套类的内部声明为私有?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    05-27 17:39
    查看更多