HOW TO CREATE IMMUTABLE CLASS?
IMMUTABLE CLASS IS A CLASS IF ONCE THEIR VALUES ARE DEFINED THE VALUES OF THAT CLASS CANNOT BE CHANGED .
THIS CAN BE DONE BY FOLLOWING STEPS:
1.CREATE A PRIVATE CLASS
2.DECLARE THE VARIABLES ONLY USING CONSTRUCTORS
3.DECLARE MEMBERS OF A CLASS WITH PRIVATE AND FINLAL
4.DONT CREATE METHODS THAT MODIFY MUTABLE CLASS
IMMUTABLE CLASS IS A CLASS IF ONCE THEIR VALUES ARE DEFINED THE VALUES OF THAT CLASS CANNOT BE CHANGED .
THIS CAN BE DONE BY FOLLOWING STEPS:
1.CREATE A PRIVATE CLASS
2.DECLARE THE VARIABLES ONLY USING CONSTRUCTORS
3.DECLARE MEMBERS OF A CLASS WITH PRIVATE AND FINLAL
4.DONT CREATE METHODS THAT MODIFY MUTABLE CLASS
No comments:
Post a Comment