Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why immutable class must be final?

class final immutable
0
Posted

Why immutable class must be final?

0

If class A is not final but immutable, and then we can set class B extends A, and change the behaviour of class B. By doing this, we successfully mutated class A. Since class B ISA class A. class A is not immutable any more.In other words: class B is a mutation from class A, therefore if class A is not final, and then class A is mutable. Just like we are all mutation from ancient African. At least some scientist said so. There are some different opinions on this issue. See the following link for details. Have some fun too. Flaming discusion on final vs. immutableMake sure you read the above.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123