question: private int pickGene ( ) { double selector = Math . abs ( random . nextDouble ( ) ) % fitnessSum ; int j = 0 ; double count = fitnesses [ j ] ; while ( count < selector && j < fitnesses . length - 1 ) { count += fitnesses [ ++ j ] ; } return j ; }
target:  Picking a gene works like a roulette wheel: a random nummer between 0 and the total population fitness is chosen. Then starting from the first index, the fitnesses of the genes are being added up sequentially,  until the sum is greater than the chosen number. The index for the last gene is the pick.  By this algorithm, the probability for a gene to be picked is proportional to it's fitness.