So I am creating an method that shuffles a group of numbers and the idea is that i create a population of these numbers. So I create a loop which shuffles the numbers and then adds it to an arraylist, however after a few debugging statements I found that it does shuffle the numbers but only adds the last shuffle to the arrayList. Can anyone help me figure out why?
solutionList is an arraylist further up the code if anyone was wondering
for(int k =0;k <100; k++){
Collections.shuffle(solutionList);
population2.add(new Object[]{solutionList}) ;
System.out.println("In the loop " + solutionList);
}
for(Object[] row : population2){
System.out.println("Row = " + Arrays.toString(row));
}