shuffle
public static void shuffle(java.util.List<?> list)
Randomly permutes the specified list using a default source of randomness.
All permutations occur with approximately equal likelihood.
This implementation traverses the list backwards, from the last element up to the second,
repeatedly swapping a randomly selected element into the "current position".
Elements are randomly selected from the portion of the list that runs from the first
element to the current position, inclusive.
This method runs in linear time.
- Parameters:
list
- - the list to be shuffled.
The performance will degrade if the list does not implement RandomAccess.
ArrayList and Vector do implement RandomAccess.