最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

Principle of information hiding in Java

2023-03-11 20:19 作者:ParisBarcelona  | 我要投稿

Here's?an analogy.

Imagine a vending machine. It has a public interface that you can use to buy snacks or drinks. You can insert coins, push buttons, and receive your purchase. However, the internal mechanism of the vending machine, such as the motor, the sensors, and the inventory, is hidden from you. You don't need to know how the vending machine works to use it.


Now, imagine that the vending machine manufacturer wants to improve the design of the vending machine. They want to change the motor, the sensors, and the inventory without affecting the public interface. They can do that, because the public interface remains the same. You can still insert coins, push buttons, and receive your purchase, even though the internal mechanism has changed.


This is similar to the principle of information hiding in Java. A class has a public interface that its clients can use, such as public methods or fields. However, the internal details of the class, such as private methods or fields, are hidden from the clients. This allows the class to change its internal details without affecting its clients, as long as the public interface remains the same.


Principle of information hiding in Java的評論 (共 條)

分享到微博請遵守國家法律
绍兴县| 临江市| 桂阳县| 阿城市| 邵阳县| 东乡县| 杭州市| 兴安盟| 叶城县| 雷山县| 阳东县| 南通市| 嘉义县| 南皮县| 客服| 祁门县| 孝昌县| 岳西县| 洞头县| 汽车| 安龙县| 托里县| 桃源县| 通化市| 孙吴县| 丹棱县| 子洲县| 雅安市| 平昌县| 琼海市| 苍溪县| 兰考县| 东台市| 定襄县| 西宁市| 彩票| 屯昌县| 江北区| 普兰县| 婺源县| 济南市|