Java final Keyword

From NovaOrdis Knowledge Base
Revision as of 20:13, 27 September 2017 by Ovidiu (talk | contribs) (→‎Overview)
Jump to navigation Jump to search

Internal

Overview

A final variable may only be assigned to once. The final variable may be defined unassigned and immediately assigned to ("definite assignment"). Once a final variable has been assigned, it always contains the same value. If the variable contain a reference of an object, the state of the referred object may change, but the variable will always refer to the same object.

An attempt to assign a final variable the second time is detected as compilation error.