up previous next contents
Next: The object class Up: Extending Classes Previous: Overriding methods, hiding fields,   Contents

Marking methods and classes final

  • No extended class can override the method to change its behavior. (This is the final version of that method.)
  • A class marked final cannot be extended by any other class (and, all the methods of a final class are implicitly final).
  • Security - anyone who uses the class can be sure the behavior will not change (validatePassword example).
  • Serious restriction on the use of the class.
  • Final simplifies optimizations.


up previous next contents
Next: The object class Up: Extending Classes Previous: Overriding methods, hiding fields,   Contents