Final (Java): Difference between revisions

Content deleted Content added
Ezrarez (talk | contribs)
m +link local variable
Ezrarez (talk | contribs)
m spelling
Line 3:
A '''final [[Class (computer science)|class]]''' cannot be [[Subclass (computer science)|subclassed]]. This is done for reasons of security or efficiancy. Accordingly, many of the Java standard library classes are final, for example [http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html java.lang.System] and <code>[[java.lang.String]]</code>. All methods in a final class are implicitly final.
 
A '''final [[Method (computer science)|method]]''' cannot be [[Method overriding (programming)|overridden]] by subclasses. This is done for reasons of efficiancy, since the method can then be placed [[Inline function|inline]] whereeverwherever it is called.
 
A '''final [[variable]]''' is a [[constant]]. It must be assigned a value at [[declaration]], and the variable can later be used but not assigned a new value. [[Local variable|Local variables]] (for example, variables in loops) cannot be declared final.