'Friends' equivalent for Java? [duplicate]

大憨熊 提交于 2019-11-28 09:39:07

(Un)fortunately, there is no direct C++ friend equivalent in Java. However, the Java access level modifiers can assist you. In particular, private or package private (AKA package protected, or "default") may help.

Ilja Preuß

You might want to use interface segregation - that is, let the class implement different interfaces, and only pass out references to the appropriate (smaller) interfaces to the different clients.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!