Java - Encapsulation 封裝
Data (or properties or attributes) and behaviour (the “methods” that operate on the data) are encapsulated into objects; moreover, the data is hidden from the external world.
Access Modifier:
| class | package | subclass (same pkg) |
subclass (diff pkg) |
world | |
|---|---|---|---|---|---|
| public | + | + | + | + | + |
| protected | + | + | + | + | |
| default | + | + | + | ||
| private | + |