国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

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

分享到微博請遵守國家法律
鲜城| 绵竹市| 成都市| 曲周县| 四会市| 南漳县| 莲花县| 营山县| 孟津县| 泾川县| 安龙县| 内乡县| 唐河县| 鲁甸县| 泉州市| 和硕县| 古蔺县| 水富县| 锦屏县| 木里| 安远县| 乌兰察布市| 连州市| 郧西县| 马龙县| 宁晋县| 宽甸| 河曲县| 林甸县| 五指山市| 防城港市| 广灵县| 镇沅| 基隆市| 邓州市| 桑植县| 招远市| 滁州市| 即墨市| 连云港市| 大同县|