java中没有和有数据隐藏的程序
我从理论上研究了java中的数据隐藏,但不知道里面发生了什么。每个教程都规定未经授权的人员无法访问他人的数据。
任何人都可以举例说明没有和有两个或三个用户以编程方式隐藏数据时会发生什么吗?
I have studied data hiding in java theoretically but don't know what is happening inside. Every tutorial, states that unauthorized persons cant access the data of others.
Can anyone please give an example of what will happen without and with data hiding with two or three users programmatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数据隐藏是向外部用户隐藏内部数据。这是通过将类的属性设置为私有并且不让类的对象直接访问它来实现的,而是我们创建 getter 和 setter 来访问私有属性。
示例:
//没有数据隐藏
//有数据隐藏
Data Hiding is hiding internal data from outside users. This is achieved by making the attributes of your class private and not letting the objects of the class access it directly, instead we create getters and setters to access the private attributes.
Example:
//Without Data Hiding
//With Data Hiding