Final (Java): Difference between revisions

Content deleted Content added
m I am not a Java programmer so I had to verify this by using Google. To my surprise none of the introduction of final variables that I found mention that final variables. So please douclecheck this
mNo edit summary
Line 44:
}
 
Immutability of variables has great advantages, especially in optimization. For instance, Sphere will probably have a function returning its volume; knowing that its radius is constant allows us to [[memoize]] the computed value of the spherevolume. If we have relatively few Spheres and we need their volumes very often, the gain might be substantial. Making the radius of a Sphere final informs developers and compilers that this sort of optimization is possible in all code that uses Spheres.
 
[[Category:Java programming language]]