How to create a Immutable class?

#2
Re: Immutable

yes we can make a class a immutable


public class final ClassName
{
---
--- all properties must be final and private
private final int i =10;

---
--- all behaviours must be final
}
 
#3
1. Announce the class Concerning illustration last thus it can't be stretched out.
2. Make know fields private thereabouts that regulate right is not permitted.
3. Don't give setter techniques to variables.
4. Aggravate all alterable fields last thereabouts that its esteem could make doled out main once.
 
Top