Performance and scalability: Immutable Class
Can anybody answer me?
What is an Immutable Class, and how to make a Class explicitly "Immutable"?
The term immutable is not appropriate.
But unfortunately this is how it is termed :-(
The term immutable is used to be mean that once an object is created, its content cannot be changed
As some one has replied "String" class is a best example of an immutable class
To create a object which is immutable u need to make sure that the following conditions are met
1)The Class should be final
2)The Properties of the class should be private and should not have any setter methods
The above mentioned are bare minimum conditions that needs to be satisfied to make the object immutable
The ideal name should have been 'RememberWhenYouModifyMeYouArePayingByCreatingNewObjects' ;)
String class is the most common example isn't it?
If u ever used the method <somestringobject>.replace u know what that-can't-pronounce-name is doing :)
immutable class is something whose state can not be changed e.g. String