<P> Although it also appears to break the intent of final variables, modifying the value from another class (by getting the reference via a public getter method and changing its value) does change the value of the referenced object . For instance, according to the semantics of the final keyword, the following unit test should output "68", while in fact it outputs "82" and throws an assertion exception: </P> <P> The reason for this is that declaring a variable final only affects the reference, not the value of the variable, and Java always passes by value, which creates a different reference to the same value in the second class . That the value of the private field can be changed without a public setter implies that encapsulation is weak at best, and shouldn't be counted on to protect key values, even in combination with the final keyword . </P> <P> When an anonymous inner class is defined within the body of a method, all variables declared final in the scope of that method are accessible from within the inner class . For scalar values, once it has been assigned, the value of the final variable cannot change . For object values, the reference cannot change . This allows the Java compiler to "capture" the value of the variable at run - time and store a copy as a field in the inner class . Once the outer method has terminated and its stack frame has been removed, the original variable is gone but the inner class's private copy persists in the class's own memory . </P> <P> The blank final, which was introduced in Java 1.1, is a final variable whose declaration lacks an initializer . A blank final can only be assigned once and must be unassigned when an assignment occurs . In order to do this, a Java compiler runs a flow analysis to ensure that, for every assignment to a blank final variable, the variable is definitely unassigned before the assignment; otherwise a compile - time error occurs . </P>

What is the meaning of final in java