title: Understanding Effective Java deep copy example
body: <p>In Effective Java, 2nd Edition, Item 11 one can find the following deep copy example:</p>
  
  <pre><code>public class HashTable implements Cloneable {
      private Entry[] buckets = ...;
  
      private static class Entry {
          final Object key;
          Object value;
          Entry next;
          Entry(Object key, Object value, Entry next) {
              this.key = key;
              this.value = value;
              this.next = next;
          }
  
          // Recursively copy the linked list headed by this Entry
          Entry deepCopy() {
              return new Entry(key, value,
                      next == null ? null : next.deepCopy());
          }
      }
      @Override public HashTable clone() {
          try {
              HashTable result = (HashTable) super.clone();
              result.buckets = new Entry[buckets.length];
              for (int i = 0; i &lt; buckets.length; i++)
                  if (buckets[i] != null)
                      result.buckets[i] = buckets[i].deepCopy();
              return result;
          } catch (CloneNotSupportedException e) {
              throw new AssertionError();
          }
      }
  </code></pre>
  
  <p>I don't understand how this makes a deep copy: key and value are objects, therefore no primitive types. So to my understanding, using</p>
  
  <pre><code>// Recursively copy the linked list headed by this Entry
  Entry deepCopy() {
      return new Entry(key, value,
              next == null ? null : next.deepCopy());
  }
  </code></pre>
  
  <p>creates a new <code>Entry</code> with a reference to the key and value of the original <code>Entry</code>? </p>
  
  <p>Doesn't a deep copy basically mean: go down until one reaches primitive types, then copy those to the clone?</p>
  
  <p>Thanks for any hint on this!</p>