Final keyword in Java
The Final keyword is used in Java on an entity that cannot be changed.
Here are a few different contexts in which final can be used:
Meaning: A final class cannot be subclassed. Advantage: Security or efficiency. Example: java.util.System
Meaning: The method cannot be overridden in a subclass. Advantage: Preventing unexpected behavior crucial to the functionality of the class.
Meaning: The variable is immutable, meaning once assigned, it cannot be reassigned. This is different from constant keyword since constant should be known at compile time and final need not be. Advantage: Optimization.
Posted at 11:06AM Mar 04, 2008 by Manveen Kaur in General | Comments[0]