title: How can I copy existing class object to other class new class object without creating copy of original object(in memory) in Java
body: <br>
  Please advise.
  I think AObj will have only one copy unless we add any changes or update the originally created object within new object. Not sure, please help.
  <br>
  <pre><code>public class AObject {
      private String a;
      Private String b;
      
      public String getA() {
          return a;
      }
      public void setA(String a) {
          this.a = a;
      }
      
  
      public String getB() {
          return b;
      }
      public void setB(String b) {
          this.b = b;
      }
  }
  }
  public class BObject{
      private AObject aObj;
      public AObject getAObj() {
          return aObj;
      }
      public void setAObj(AObject aObj) {
          this.aObj = aObj;
      }
  }
  public static void main(String[] args){
      AObject aObj = new AObject();
      aObj.setA(&quot;testA&quot;);
      aObj.setB(&quot;testB&quot;);
  
      BObject bObj = new BObject();
      bObj.setAObj(aObj) //here I would like to avoid creating the deep copy of objects.
  }
  </code></pre>