title: Confusion about cloneable interface and object.clone() in java
body: <p>If I have: </p>
  
  <pre><code>class foo implements Cloneable
  </code></pre>
  
  <p>and then do:</p>
  
  <pre><code>bar = new foo();
  bar.clone();
  </code></pre>
  
  <p>I get a shallow copy without needing to write any <code>bar.clone()</code> code like I normally would need to do when I implement an interface.</p>
  
  <p>My understanding is that an interface's functions must be filled in by the class implementing it, and <code>Object.clone()</code> has no implementation (as per the docs, "The class Object does not itself implement the interface Cloneable")</p>
  
  <p>So where does my shallow clone come from? Where is the code that implements <code>bar.clone()</code> if <code>Object.clone()</code> has no implementation? I'm confused.</p>