I heard this line somewhere and I cannot get it off of my mind:
"All members of a final class are implicitly final."
Now, I know very well these three famous concepts:
final
class cannot be extended.final
variable cannot be re-assigned with a new value once initialized.final
method cannot be overridden.But, if all members (variables, methods) of a final class are implicitly final, then we have a final class AND final variables AND final methods in it.
Then, how is it possible that StringBuilder
, despite being final, allows its contents to change?!
That assertion is oversimplified and therefore wrong. Only methods of a final
class can be considered implicitly final
. This fact is however irrelevant in itslef, as methods of a final
class cannot be overriden because there can't be any subclasses. It doesn't really matter if they're final
or not, implicitly or explicitly.