Java examples for Object Oriented Design:final
The final modifier is used with classes, methods, and variables to tell that they will never change.
It has different meanings.
A final class cannot be subclassed.
A final method cannot be overridden by any subclasses.
A final variable cannot change in value.
Final variables are called constants because they do not change in value at any time.
The following statements are examples of declaring constants:
public static final int CONST = 6; static final String TITLE = "test";
Final methods never can be overridden by a subclass.
public final void getSignature () { // body of method }
To disable a class to have subclass, use the final modifier in the class's declaration.
public final class ChatServer { // body of method }