I have a bit doubt in the case of final and immutable classes in java, please explain the concepts with example .
is it both having same meaning ??
awaiting for genuine reply......
When a class is final, it just means that you cannot subclass it. Immutable means that you cannot change the state of an object after it has been created. Making classes immutable has many advantages, see this article for more details.
When you want to make a class immutable, you should make it final. But just making it final does not by itself make the class immutable.
Jesper de Jong wrote:When a class is final, it just means that you cannot subclass it. Immutable means that you cannot change the state of an object after it has been created. see this article for more details.
yes! this is pretty enough to clear my doubt...
Thanks ... Jesper!