Quick revision
The short answer
final means "cannot be changed after this point", applied to different things: a final class cannot be subclassed, a final method cannot be overridden, a final field must be assigned exactly once, in its initializer or on every constructor path, and a final local variable or parameter cannot be reassigned. final applies to the reference, not the object, so a final List can still be modified. Final fields also get a special guarantee in the Java Memory Model: other threads see their constructed values once construction completes, without synchronization.
What to remember
In this answer, we saw that final means no subclasses on a class, no overriding on a method, exactly one assignment on a field, and no reassignment on a local or parameter, and that lambdas and inner classes can only capture final or effectively final locals. final freezes references, not objects, so a final List can still change unless we use an unmodifiable list. Final fields also carry a memory model guarantee: properly constructed objects show their final fields correctly to every thread, which is what makes immutable objects safe to share.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
final means "cannot be changed after this point", applied to different things: a final class cannot be subclassed, a final method cannot be overridden, a final field must be assigned exactly once, in its initializer or on every constructor path, and a final local variable or parameter cannot be reassigned. final applies to the reference, not the object, so a final List can still be modified. Final fields also get a special guarantee in the Java Memory Model: other threads see their constructed values once construction completes, without synchronization.
Why this question is asked
final is one of the most used keywords in Java, and one of the most misunderstood, because it means slightly different things in four places. The most common mistake in real code is believing that a final field makes an object immutable, which leads to shared lists being changed in surprising places. Interviewers ask this to check both the rules and that misunderstanding. In this answer, we will go through final on classes and methods, on fields, and on locals and parameters, see exactly what final does not protect, and finish with the memory model guarantee that makes final fields special for concurrency.
1Final on Classes and Methods
A final class cannot be extended. String, Integer and the other wrapper classes are final, which is part of why they are safe to share: nobody can create a subclass of String that behaves differently. A final method cannot be overridden by subclasses, though the class itself can still be extended.
We make a class final when we have not designed it for extension and want to keep the freedom to change its internals, and a method final when its behaviour is part of a contract subclasses must not break. Records and enums are implicitly final, or effectively so, for the same reason.
2Final on Fields
A final field must be assigned exactly once. Either it has an initializer, or every constructor must assign it on every path, and the compiler checks that. A final field without an initializer is called a blank final.
A static final field follows the same rule, but it must be assigned in its initializer or in a static block. A static final field of a primitive or String type with a constant initializer, such as static final int MAX = 50, is a constant variable, and the compiler copies its value into every place that uses it.
3Final on Local Variables and Parameters
A final local variable or parameter cannot be reassigned after it gets its value. Many teams write final on parameters to make reassignment impossible, while others find it noisy.
More important is the related idea of effectively final: a local variable that is never reassigned, even without the keyword. Lambdas, anonymous classes and local classes may only use local variables that are final or effectively final, because they capture a copy of the value.
The reason for the rule is that the lambda keeps a copy of the value. If the variable could change later, the copy and the original would disagree, so Java forbids the situation instead of picking one.
4What final Does Not Protect
final freezes the reference stored in the variable, not the object the reference points to. A final field holding a List cannot be pointed at a different list, but the list itself is as mutable as ever.
| Applied to | Effect | Does not stop |
|---|---|---|
| class | no subclasses | changing the object's fields |
| method | no overriding | overloading with other parameters |
| field | assigned exactly once | changes inside the referenced object |
| local or parameter | no reassignment | changes inside the referenced object |
To make the contents unchangeable, we need an unmodifiable object as well, such as List.of(...) or List.copyOf(input) taken in the constructor. A truly immutable class combines three things: final fields, values that are themselves immutable or defensively copied, and no methods that change state.
5The Memory Model Guarantee for Final Fields
Final fields have one more property that matters for concurrent code. The Java Memory Model promises that if an object is constructed without letting this escape, any thread that obtains a reference to it sees the final fields with the values the constructor gave them, even if the reference was passed through a data race without synchronization. Non-final fields have no such promise; another thread might see their default values.
This is what lets immutable objects such as String be shared freely between threads. The guarantee also covers objects reached through the final field, such as the elements of a final array filled in the constructor, as they were when the constructor ended.
6Follow-up questions
Does final make code faster?
Rarely in a measurable way. The JIT compiler already knows which methods are not overridden in the loaded classes and inlines them, so final methods are not much faster. The real benefits of final are design and correctness: fewer surprises, safe publication and clear intent.
Can reflection change a final field?
For ordinary instance fields, Field.setAccessible(true) followed by set() can still change a final field today, but the JVM may not make the change visible to code that already read or inlined the value. Static final fields, record fields and fields of hidden classes cannot be changed this way, and the JDK is moving towards restricting final field mutation further, so check your version.
Why are record fields final?
A record is meant to be a transparent carrier of its values, defined by its components. Making the fields final guarantees that a record's state is fixed after construction, which keeps equals and hashCode stable and makes records safe to share. Like any final field, though, a component that holds a mutable list is still mutable inside.
7Conclusion
In this answer, we saw that final means no subclasses on a class, no overriding on a method, exactly one assignment on a field, and no reassignment on a local or parameter, and that lambdas and inner classes can only capture final or effectively final locals. final freezes references, not objects, so a final List can still change unless we use an unmodifiable list. Final fields also carry a memory model guarantee: properly constructed objects show their final fields correctly to every thread, which is what makes immutable objects safe to share.
Open with
final means the thing cannot change after a point, but what changes is different in each place. On a class it means no subclasses, like String; on a method it means subclasses cannot override it.
Then, if they want more
On a field it means it is assigned exactly once, either in its initializer or on every constructor path, and the compiler checks that; a static final with a constant initializer becomes a constant the compiler inlines.
On a local variable or parameter it means no reassignment, and related to that, lambdas and inner classes can only capture locals that are final or effectively final, because they capture a copy. The important limit is that final applies to the reference, not the object.
A final List field cannot point to a different list, but anyone holding it can still add to it, so for immutability I combine final fields with immutable values, such as List.copyOf in the constructor, and no mutating methods.
Final fields also have a Java Memory Model guarantee: if the object is constructed without this escaping, every thread that sees the reference sees the constructed values of its final fields, even without synchronization, which is what makes immutable objects safe to share between threads.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- The Java Language Specification, Java SE 21, Java SE 21 API documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "What does final mean on a class, a method, a field and a local variable? Does a final...": https://scrivio-interview-library.netlify.app/java/classes-and-objects/2d14ac20a9/