Possible Duplicate:
How do I copy an object in Java?
Is it ok to do like this in java?
public class CacheTree {
private Multimap<Integer, Integer> a;
private Integer b;
public void copy(CacheTree anotherObj) {
this.a = anotherObj.getA();
this.b = anotherObj.getB();
}
public Multimap<Integer, Integer> getA() {
return a;
}
public Integer getB() {
return b;
}
}
public void main() {
CacheTree x = new CacheTree();
CacheTree y = new CacheTree();
x.copy(y); // Is it ok ?
}