How to create Immutable Class In Java
How to create Immutable Class In Java Hi all, its been a long time . Was really busy with work :).Got some time now to learn new things again .Today I am going to explain you all how to create immutable class in java.First of all what is immutable ? Immutable means can't be changed once created. Immutable Class: Immutable classes are the one which cant be extended by any other sub class and should not able to change the value of any mutable and immutable variable inside the class, should not allow the methods to get override. Properties of Immutable Class: Let me tell you the properties an immutable class should hold. Class should be final All the variable inside the class should be private final All the method should be final Don't create any setter methods Create a constructor to initialize all the variables Provide a public get method for all the variables, for mutable object clone and ...