I was reading Effective java Third edition. The topic is
Item 17 : Minimize mutabitity
In this topic Immutable Objects are discussed and also alternative way to not to make class final but still it will be immutable.
Here is what is written in the topic:
Recall that to guarantee immutability, a class must not permit itself to be sub classed. This can be done by making the class final, but there is another, more flexible alternative. private or package-private and add public static factories in place of public constructor.
I can agree on making a constructor private it will make the class unable to be sub classed. But class with package private constructor can be sub classed with in the package. So will the class still be immutable with package private constructor?
Edit 1 :
The class with package private constructor is still immutable for class outside the package. But is this approach helpful?