final – some quick facts

  • A final class can’t be a base class
  • A final method can’t be overridden
  • A final variable is a constant.
  • Generally you should avoid declaring final methods, though you think that a subclass wouldn’t need to override a method
  • final methods execute a bit more efficiently than non-final methods, because the compiler knows at compile time that a call to a final method can’t be overridden.
  • private methods are automatically considered as final
  • Though it is not required, using a static keyword is common for all final variables.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s