Final (Java): Difference between revisions

Content deleted Content added
SAE1962 (talk | contribs)
m Final variables: Link stated more precisely. Small corrections done.
No edit summary
Line 52:
</source>
Immutability of variables has great advantages, especially in optimization. For instance, <code>Sphere</code> will probably have a function returning its volume; knowing that its radius is constant allows us to [[memoize]] the computed volume. If we have relatively few <code>Sphere</code>s and we need their volumes very often, the gain might be substantial. Making the radius of a <code>Sphere</code> <code>final</code> informs developers and compilers that this sort of optimization is possible in all code that uses <code>Sphere</code>s.
 
==External links==
* [http://javapapers.com/java-interview-questions/explain-the-final-keyword-in-java/ Discussion about a controversy on final keyword]
 
[[Category:Java programming language]]