How can I stop inheritance?

We can stop inheritance by declaring class as a final. So final keyword is very important for stopping to inheritance. We should keep in mind about final as:

  • final variables can't be modified.
  • final method can't be overridden.
  • final class can't be inherited.


Post a Comment