dimanche 2 décembre 2018

Immutable pattern requirments

I am studying Immutable pattern using java , but i can't understand the following two requirements : 1 ) Instance methods which access properties must not change instance variables 2 ) Ensure that the constructor of the immutable class is the only place where the values of instance variables are set or modified. Please someone give a simple example for the first point. For the second point , i can't understand how we can modify the variables through the constructor while they are final ?

Aucun commentaire:

Enregistrer un commentaire