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

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
文成县| 富锦市| 江门市| 龙州县| 竹山县| 武陟县| 芦溪县| 余干县| 黄浦区| 杭州市| 左云县| 莱芜市| 广德县| 紫阳县| 政和县| 澜沧| 峨山| 梁平县| 西青区| 临江市| 瑞昌市| 丹寨县| 内丘县| 乌兰浩特市| 太谷县| 庆云县| 罗甸县| 永和县| 兴和县| 临城县| 桃园县| 民丰县| 新竹市| 沛县| 汝阳县| 昭觉县| 萨嘎县| 上饶市| 淳安县| 东丽区| 宁安市|