Deep copying and genetic algorithm
<p>I am working on a project at the moment to try create a simple genetic algorithm. Regarding structure, I have a Gene that is char [] with four numbers and a chromosome which is an array of 10 gene objects. </p>

<p>I am trying to write a simple crossover method that creates a child from half of each of the parent chromosomes. I started with the approach below but soon realised I was just shallow copying. I have spent the last few days reading numerous posts on using the cloneable interface to implement deep copying but I have been unsuccessful with all attempts. Please could someone help me with this issue. Any tips and pointers would be grately appreciated</p>

<pre><code>public Chromosome createChild (Chromosome parentA, Chromosome parentB)
{
    Chromosome child=new Chromosome();
    for (int i=0;i&lt;10; i++)
    {   
        if (i&lt;5)
        {
            child.genes[i] = parentA.genes[i]; 
        }
        else
        {
            child.genes[i] = parentB.genes[i];
        }

    }   
    return child;       
}
</code></pre>
