title: how to deep copy object in java?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/869033/how-do-i-copy-an-object-in-java">How do I copy an object in Java?</a>  </p>
  </blockquote>
  
  
  
  <p>Is it ok to do like this in java?</p>
  
  <pre><code>public class CacheTree {
  
      private Multimap&lt;Integer, Integer&gt; a;
      private Integer                    b;
  
          public void copy(CacheTree anotherObj) {
              this.a = anotherObj.getA();
              this.b = anotherObj.getB();
          }
  
         public Multimap&lt;Integer, Integer&gt; 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 ?
  }
  </code></pre>