I'm trying to get Collections.shuffle() to shuffle only one array is a list of 3 arrays made using Collections.nCopies() (ex: I only want it to shuffle the first array, but it ends up shuffling every array in the list)
Here's what I've done so far. I have been trying to look through Google for the same problem but the only examples provided are Strings or Integers, no Arrays.
x is 3 and slotType.getSlotitems() is for the array ["Apple","Cherry","Banana"]
List<ArrayList<String>> q = Collections.nCopies(x,slotType.getSlotitems());
for (ArrayList<String> v : q) {
java.util.Collections.shuffle(v);
System.out.println(v);
System.out.println(q);
}
The result that shows up is:
[Cherry, Banana, Apple]
[[Cherry, Banana, Apple], [Cherry, Banana, Apple], [Cherry, Banana, Apple]]
[Cherry, Banana, Apple]
[[Cherry, Banana, Apple], [Cherry, Banana, Apple], [Cherry, Banana, Apple]]
[Cherry, Apple, Banana]
[[Cherry, Apple, Banana], [Cherry, Apple, Banana], [Cherry, Apple, Banana]]