Our website is made possible by displaying online advertisements to our visitors.
Please consider supporting us by disabling your ad blocker.

Responsive image


Final (Java)

In the Java programming language, the final keyword is used in several contexts to define an entity that can only be assigned once.

Once a final variable has been assigned, it always contains the same value. If a final variable holds a reference to an object, then the state of the object may be changed by operations on the object, but the variable will always refer to the same object (this property of final is called non-transitivity[1]). This applies also to arrays, because arrays are objects; if a final variable holds a reference to an array, then the components of the array may be changed by operations on the array, but the variable will always refer to the same array.[2]

  1. ^ Coblenz, Michael; Sunshine, Joshua; Aldrich, Jonathan; Myers, Brad; Weber, Sam; Shull, Forrest (14–22 May 2016). "Exploring Language Support for Immutability". The 38th International Conference on Software Engineering.
  2. ^ Java Language Specification #4.12.4

Previous Page Next Page