Final (Java): Difference between revisions

Content deleted Content added
Line 16:
 
Example:
<source lang="java">
 
public class MyClass {
public final void myFinalMethod() {...}
}
</source>
 
 
A common misconception is that declaring a class or method final improves efficiency by allowing the compiler to directly insert the method inline where ever it is called. This is not completely true; the compiler is unable to do this because the classes loaded at runtime might not be same versions of the ones that were just compiled. Further, the runtime environment and [[JIT]] compiler have the information about exactly what classes have been loaded, and are able to make better decisions about when to inline, whether or not the method is final.[http://www.ibm.com/developerworks/java/library/j-jtp1029.html]
 
 
= Final variables =