Chromosome implements Comparable<Chromosome>,Fitness { public int compareTo(final Chromosome another) { return Double.compare(getFitness(), another.getFitness()); }  double getFitness(); int compareTo(final Chromosome another); void searchForFitnessUpdate(final Population population);  }
@Test public void testCompareTo() { Chromosome c1 = new Chromosome() { public double fitness() { return 0; } }; Chromosome c2 = new Chromosome() { public double fitness() { return 10; } }; Chromosome c3 = new Chromosome() { public double fitness() { return 10; } }; Assert.assertTrue(c1.compareTo(c2) < 0); Assert.assertTrue(c2.compareTo(c1) > 0); Assert.assertEquals(0,c3.compareTo(c2)); Assert.assertEquals(0,c2.compareTo(c3)); }