ListPopulation implements Population { public Chromosome getFittestChromosome() { Chromosome bestChromosome = this.chromosomes.get(0); for (Chromosome chromosome : this.chromosomes) { if (chromosome.compareTo(bestChromosome) > 0) { bestChromosome = chromosome; } } return bestChromosome; } ListPopulation(final int populationLimit);  ListPopulation(final List<Chromosome> chromosomes, final int populationLimit); @Deprecated void setChromosomes(final List<Chromosome> chromosomes); void addChromosomes(final Collection<Chromosome> chromosomeColl); List<Chromosome> getChromosomes(); void addChromosome(final Chromosome chromosome); Chromosome getFittestChromosome(); int getPopulationLimit(); void setPopulationLimit(final int populationLimit); int getPopulationSize(); @Override String toString(); Iterator<Chromosome> iterator();  }
@Test public void testGetFittestChromosome() { 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 15; } }; ArrayList<Chromosome> chromosomes = new ArrayList<Chromosome> (); chromosomes.add(c1); chromosomes.add(c2); chromosomes.add(c3); ListPopulation population = new ListPopulation(chromosomes, 10) { public Population nextGeneration() { return null; } }; Assert.assertEquals(c3, population.getFittestChromosome()); }