title: shallow copy - new instance Or assignment
body: <p>Shallow copy means a <strong>"copy"</strong> of an object with same values of their attributes whether primitive or reference values.</p>
  
  <p>While performing shallow copy is it necessary to "<em>create a new instance</em>" ? as:</p>
  
  <pre><code>public class A {
      int aValue;
      B bObj;
  
      ...
  
      public A createShallow(A a1Obj) {
          A aObj = new A();
          aObj.aValue = a1Obj.aValue;
          aObj.bObj = a1Obj.bObj;
  
          return aObj;
      }
  }
  </code></pre>
  
  <p>Or  copy <em>by assignment</em> is also considered as shallow copy:</p>
  
  <pre><code>B b = new B(10);
  A a = new A(1, b);
  
  A a1 = a;
  </code></pre>
  
  <p>This <a href="http://en.wikipedia.org/wiki/Object_copy" rel="nofollow">article</a> at wikipedia defines shallow copy as reference variables <em>sharing same memory block</em>. So according to this copy by assignment will also be a shallow copy. </p>
  
  <p>But is not it a <em>variables pointing to same object</em> instead of <em>"copy"</em> of an Object ?</p>