Final (java) Article Index for
Final
Website Links For
Final
 

Information About

Final (java)




A '''final . All methods in a final class are implicitly final.

Example:

public final class MyFinalClass {...}

A 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 {
public final myFinalMethod() {...}
}

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 {
public static final float PI = 3.1415;
}