title: ArrayList (completely deep copy)
body: <p>Before entering question, I know other than primitive type, everything is stored by its reference number. My java code structure is something like this..... First I have driver, reservation and car classes. The relationship between them is driver is a driver who performed reservation and car is booked up to be driven that is stored in reservation class. </p>
  
  <p>Driver will take care of reservation. Cars have a few primitive types information. Multiple cars can be stored into the reservation (primitive and <code>ArrayList</code>). But one driver (<code>ArrayList</code>) (from driver class) can have multiple reservations. So, when I allow users to view what driver has in his reservations, I would like to deep copy everything in the <code>ArrayList</code> since everything except for primitive types are reference numbers.</p>
  
  <p>Anyway, I will make a copy of array list for reservation in driver class.</p>
  
  <p>In my driver class, and this is a accessor and when it is passing the <code>ArrayList</code>, I attempted to deep copy first and pass the <code>ArrayList</code>.</p>
  
  <pre><code>public ArrayList&lt;Reference&gt; getReference() {    
  
      copiedRef = new ArrayList&lt;Reference&gt;();
  
      //references have been declared above
      for (int i = 0; i &lt; references.size(); i++) {
          copiedRef.add(references.get(i));
          //getting each element in the arrayList one by one and push to a new ArrayList
      }
  
      return copiedRef;
  }
  </code></pre>
  
  <p>Is this doing deep copy? And if I need to use <code>clone()</code>.</p>
  
  <p>How would I improve? (<code>clone</code> does shallow copy, I don't think <code>clone</code> can help for deep copy or I could misunderstand other posts).</p>