What would be the best way to copy/clone an object in java/android?
rlBodyDataObj rlbo = bdoTable.get(name);
Right now the code assigns an
i wish to implement with : copy constructor
class DataObj {
private String tag;
public DataObj(DataObj another) {
this.tag= another.tag; // you can access
...
}
}
Every object has also a clone method which can be used to copy the object, but It's way too easy to create a class and do improper clone method. If you are going to do with implement clone method, read at least what Joshua Bloch has to say about it in Effective Java.