Final
Final is a language modifier that restricts reassignment, inheritance, or overriding of declarations according to the language's rules.
100 Java Mistakes and How to Avoid Them
The final modifier is a Java declaration modifier that prevents reassignment of a local variable after its initialization or assignment.
- How it is used
- Guards branch results and inherited behavior against unintended reassignment or overriding.
- How deep it goes
- Explains final through conditional assignments, method hooks, and exact-class tests, without a general declaration taxonomy.
- Examples
- Uses a branch-selected Data value, key-event handling hooks, and Date/Calendar runtime-class conversion.
- What you can do after
- Diagnose/debug with it, exposing duplicate conditional assignments and protecting required superclass behavior.
Read how 100 Java Mistakes and How to Avoid Them explains final →
Kotlin in Action, 2E
The final modifier prevents a Kotlin class from being subclassed or a class member from being overridden.
- How it is used
- Controls class inheritance and member overriding while making intended extension points explicit.
- How deep it goes
- Explains default restrictions, explicit open points, final overrides, and the fragile base class problem without descending into compiler internals.
- Examples
- Uses RichButton and ThemedButton to separate overridable animation behavior from protected button behavior.
- What you can do after
- Evaluate/understand how to design Kotlin hierarchies with deliberate subclassing and overriding boundaries.
Learn C++ by Example
The final specifier is a C++ specifier that prevents a virtual function from being overridden or a class from being used as a base class.
- How it is used
- Prevents unwanted virtual overrides and inheritance in polymorphic C++ designs.
- How deep it goes
- Covers function and class restrictions with compile-time consequences, but does not develop implementation internals.
- Examples
- Uses StepperBlob, DerivedStepper, and a race example to demonstrate class-level inheritance prevention.
- What you can do after
- Apply it via C++ declarations to stop selected overrides or prevent a class from becoming a base class.
Related concepts
- valequivalent to · val is a Kotlin declaration form for a variable or property whose binding cannot be reassigned after initialization.
- immutable collectioncontrasts with · An immutable collection is a collection whose membership and contents cannot be changed after creation.
- identityaddresses · Identity is the property or representation by which an entity is distinguished and recognized as that particular entity.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


