DEV Community

Discussion on: Explain what really happening when you put final in a class Like I'm Five

Collapse
 
mohr023 profile image
Matheus Mohr

Yes, on it's own, the final modifier prevents a class from being extended. There are some workarounds for that, like delegating the final class calls through another (Foo is final, so you create Bar with the same interface as Foo, make it redirect every call to Foo's methods, and then extend Bar when you need. This is specially useful when you have absolutely no way of changing the code and still want to reuse it's functionalities)