Tim Weide wrote:Why would you want to write a mutable class?
if want to perform any modification on existing object with those changes a new Object will be created this concept is nothing but immutability......
sample code is
final public class MyImmutable{
private int var1=0;
public MyImmutable(int var1){
this.var1=var1;
}
public MyImmutable getModify(int var1){
if(this.var1==var1){return this;}
else
return new MyImmutable(var1);
}
}