Final method
The keyword final in front of a method makes it impossible to override it in a child class instance or hide if, the method is static. It provides an assurance that the method functionality cannot be changed through overriding. The class java.lang.Object, for example, has many of its methods as final.
But if a final method uses non-final ones, this may allow for the backdoor introduction of undesirable changes. Naturally, such considerations are very important for security.
Sometimes, one can read that making methods final can improve code performance. It may be the case, but in some very specific situations and does not seem to help significantly in mainstream programming. For performance improvements, there are usually much ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access