Rule:

  • Create a class as Final, which should not too accessible to others.
  • Makes all fields private to prevent direct access to others.
  • hide setters methods
  • All mutable fields should be final whose value should not be changeable after assigned ones.
  • Initialize all fields using constructors.
  • Provide the getter method and from the same return the only clone of the object rather than returning to actual objects.

What is immutable

  1. Things which can not change once they are prepared fully, or in other words can say once object is created with initialized value ,then it cant be change any how.