title: Does java.lang.System.arraycopy() use a shallow copy?
body: <p><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#arraycopy(java.lang.Object,%20int,%20java.lang.Object,%20int,%20int)" rel="nofollow"><code>System.arraycopy()</code></a> is a shallow copy method. </p>
  
  <p>For an array of a primitive type, it will copy the values from one array to another:</p>
  
  <pre><code>int[] a = new int[]{1,2};
  int[] b = new int[2];
  System.arraycopy(a, 0, b, 0, 2);
  </code></pre>
  
  <p><code>b</code> will be {1,2} now. Changes in <code>a</code> will not affect <code>b</code>.</p>
  
  <p>For an array of a non-primitive type, it will copy the references of the object from one array to the other:</p>
  
  <pre><code>MyObject[] a = new MyObject[] { new MyObject(1), new MyObject(2)};
  MyObject[] b = new MyObject[2];
  System.arraycopy(a, 0, b, 0, 2);
  </code></pre>
  
  <p><code>b</code> will contain a reference of  <code>new MyObject(1)</code>, <code>new MyObject(2)</code> now. But, if there are any changes to <code>new MyObject(1)</code> in <code>a</code>,  it will affect <code>b</code> as well.</p>
  
  <p>Are the above statements correct or not?</p>