title: Copy constructor for abstract class
body: <p>I have an abstract class named <code>AClass</code>. In the same package I have <code>AnotherClass</code>, in which I have an <code>ArrayList</code> of <code>AClass</code> objects. In the copy constructor of <code>AnotherClass</code> I need to make a duplicate of <code>AClass</code> objects inside the <code>ArrayList</code>. </p>
  
  <p>The problem:</p>
  
  <p>I cannot create a copy constructor in <code>AClass</code> because it is an abstract class and I cannot know the name of the class which will inherit by <code>AClass</code>. Actually, in this project, no object will inherit from this class, but this project will be used as a library by other projects which will provide a class child of <code>AClass</code>. Is there an error in my design or is there a solution to this problem?</p>
  
  <p><strong>Edit</strong>: here's some code:</p>
  
  <pre><code>public class AnotherClass{
      private ArrayList&lt;AClass&gt; list;
  ...
      /** Copy constructor
      */
      public AnotherClass(AnotherClass another){
          // copy all fields from "another"
          this.list = new ArrayList&lt;AClass&gt;();
          for(int i = 0; i &lt; another.list.size(); i++){
              // Option 1: this.list.add(new AClass(another.list.get(i)));
              // problem: cannot instantiate AClass as it is abstract
              // Option 2: this.list.add(another.list.get(i).someKindOfClone());
              // problem? I'm thinking about it, seems to be what dasblinkenlight is suggesting below
          }
      }
  ...
  }
  </code></pre>