1.3 The hidden implementation
Access control enables users to solve their particular problems without thinking about the inner construction. Also, it allows the programmer to update the internal working without worrying about how the change will affect the client programmer.
Java has three keywords to set the boundaries: public, private and protected.
protected acts like private, except that an inheriting class has access to protected members, but not private members.
"friendly" access allows classes to access the friendly members of other classes in the same package.
博客介绍了访问控制的作用,它能让用户解决问题时无需考虑内部构造,也让程序员更新内部工作时不必担心影响客户端。还提到Java有public、private、protected三个设置边界的关键字,protected类似private但继承类可访问,此外还有“friendly”访问,允许同包类访问友好成员。
&spm=1001.2101.3001.5002&articleId=104849&d=1&t=3&u=2a92b159be054758bb93e167e07e7851)
340

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



