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.
Also covered in
- Data-Oriented Programming in JavaIn early access (MEAP)
What to know first
- attributeAn attribute is a named property or piece of information associated with an entity, object, or structured data item.
- initializerAn initializer is a function, declaration, or language construct that establishes an initial value or state for an object, value, or computation.
- classA class is a programming-language construct that defines a type’s structure and behavior and provides a basis for creating or representing objects.
Related concepts
- value semanticsuses · Value semantics are rules under which an entity is defined by stable descriptive values rather than by changeable state or identity.
- 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 contents cannot be changed after it is created.
- identityaddresses · Identity is the property or information by which an entity is distinguished and recognized as a particular entity, apart from the equality of its current attributes or state.
Questions about final
What is final?
Final is a language modifier that restricts reassignment, inheritance, or overriding of declarations according to the language's rules.
Which Manning books explain final?
100 Java Mistakes and How to Avoid Them, Kotlin in Action, 2E and Learn C++ by Example.
What should I know before learning final?
Manning books that teach final usually introduce attribute, initializer and class first.
What is the difference between final and immutable sequence?
Final is a language modifier that restricts reassignment, inheritance, or overriding of declarations according to the language's rules. An immutable sequence is an ordered collection whose contents cannot be changed after creation, with updates producing a separate sequence.
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.


