NOTE
Immutable Object
Immutable objects do not change state after construction. These notes examine constraints such as final classes and fields when constructing them.
This is a historical learning note and may contain outdated or incomplete understanding.
How to Create an Immutable Object
- Apply
finalto the class. - Apply
finalto internal fields.- If the field is a reference to an object:
- Do not expose a method that modifies the internal field value.
- If it is returned externally, return a copied object.
- If the field is a reference to an object:
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub