I need to copy all content of class object to new class object. I don't need to copy references to data, because in that case if I change fields in object a2 those data will be changed in object a2.
public class Msg {
String info="";
HashMap fld = new HashMap();
public void assign(Msg value) {
info = value.infol;
fld = value.fld;
}
}
// Do stuff with class
a1 = new Msg();
a1.info="111";
a1.fld.put("1","111");
a2 = new Msg();
a2.assign(a1);
How to realise function assign
?