java encapsulation
来源:互联网 发布:mac双系统卸载windows 编辑:程序博客网 时间:2024/06/04 19:47
Encapsulation in Java is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as as single unit. In encapsulation the variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class, therefore it is also known as data hiding.
To achieve encapsulation in Java
Declare the variables of a class as private.
Provide public setter and getter methods to modify and view the variables values.
Benefits of Encapsulation:
The fields of a class can be made read-only or write-only.
A class can have total control over what is stored in its fields.
The users of a class do not know how the class stores its data. A class can change the data type of a field and users of the class do not need to change any of their code.
- java encapsulation
- Java Tutorial 4 Encapsulation
- java之封装 Encapsulation
- encapsulation
- java 封装,Encapsulation in Java
- thinking in java(IV)--encapsulation
- java笔记-封装(Encapsulation)
- java的封装特性(Encapsulation)
- Java--封装(encapsulation)和private关键字
- Java面向对象编程之封装(encapsulation)
- Java - Encapsulation封装(面向对象1-封装)
- XML Encapsulation
- good encapsulation
- Encapsulation小记
- 封装 Encapsulation
- 直接来第一篇吧----JAVA的三大特性之一:封装(Encapsulation)
- Reflection vs Encapsulation – Stand Off in the Java Module System(1)
- Reflection vs Encapsulation – Stand Off in the Java Module System(2)
- HUST 1353 Dartboard
- Factory
- 不错的链接地址
- HUST 1354 Rubiks
- oracle重复数据操作
- java encapsulation
- Linux常用命令之六:关机
- Xcode7 配置pch文件
- 信息指纹
- Android编程之LayoutInflater的inflate方法详解
- HUST 1358 Uiwurerirexb jeqvad
- 安卓 ImageView ACTION_UP&DOWN监听
- [iOS]The app icon set named "AppIcon" did not have any applicable content
- 现在的问题