The Final Keyword
The final keyword determines whether an object
reference can be changed
after being assigned. In the kite example, using the final keyword would
be akin to supergluing the string to your hand. The final keyword is often
used in conjunction with the static keyword to create constants. However, it’s
important to note that the final keyword does not prevent an object’s
internal
state from changing. The final keyword can also be applied at the class level
to prevent subclasses from extending a class, or at the method level to prevent
subclasses from overriding a method.
The Static Keyword
The static keyword determines whether a property belongs to a class or to
an object instance. For example, imagine holding a blueprint for a house.
Properties that can be unique between houses, such
as the number of windows
or doors, are examples of instance properties. Properties that can be written
on the blueprint, such as the number of houses built,
are examples of static
properties. An object can access static properties on a class, but a class cannot
access instance properties unless it holds a reference to an object.