Final (Java)
Encyclopedia : F : FI : FIN : Final (Java)
In the Java programming language, the final keyword is used in several different contexts to define an entity which cannot later be changed.
A final class cannot be subclassed. This is done for reasons of security or efficiency. Accordingly, many of the Java standard library classes are final, for example and . All methods in a final class are implicitly final.
Example:
public final class MyFinalClassA final method cannot be overridden by subclasses. This is done for reasons of efficiency, since the method can then be placed inline wherever it is called.
Example:
public class MyClass }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 variables (for example, variables in loops) cannot be declared final.
Example:
public class MyClass
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
