Q:

Collections.shuffle only working once

I checked a previous answer but it didn't work for me.
I have the following code
public static void createPopulation(ArrayList<City> city)
{
    for (int i = 0; i<gen.getSize(); i++)   {   
        ArrayList<City> copy = new ArrayList<City> (city); //added from previous question
        Collections.shuffle(copy, new Random(seed));
        gen.add(copy);
    }
}

It shuffles once, with or without the line with the comment on it, but doesn't shuffle again. It's a GP algorithim (well, the start of it) where I have to shuffle the members of a population.

A:

That's because you recreate the Random object.
Do this :
Random r = new Random(seed);
for (int i = 0; i<gen.getSize(); i++)   {   
    ArrayList<City> copy = new ArrayList<City> (city); //added from previous question
    Collections.shuffle(copy, r);
    gen.add(copy);
}

From the javadoc :

If two instances of Random are created with the same seed, and the
  same sequence of method calls is made for each, they will generate and
  return identical sequences of numbers.

An instance of Random is a generator whose state is changed each time you call a random function on it. Here you don't want to reset this state to the initial seed based one, because that would lead to the same sequence of returned numbers. That's why you don't want to recreate a new instance for each shuffling.

