Why does CheckStyle suggest using the latter method?

I am using the eclipse checkstyle plugin. I have several methods in class A that are overridden in class B. I have the following warning for most methods

A function is SearchAndReplacenot considered inherited
- it must be declared abstract or final, or left empty.

Are there any advantages to declaring a method as final?

EDIT

I know what the final keyword is suitable for. I know this prevents overriding methods, are there any other benefits like performance or something like that?

+5
source share
4 answers

, , .

Java:

.

, .

(- , )

                         

, , (, , ( virtual Java)), .

+12

A final , . , ( ).

final , , . (, , bool checkSecurity() - !)

+4

Java final :

- , , , .

0

When a method is declared final, it is safe to call in the constructor (unless other non-final methods are involved in it). If these are not final subclasses, he can override it in a way that attempts to access the fields entered in the subclass. And that often will not be what you expect. I think there are some performance benefits when you write for mobile, but I'm not an expert there.

0
source

All Articles