The Collections.shuffle () method does this for you, you do not need to explicitly specify.
"If the specified list does not implement the RandomAccess interface and is large, this shuffle () implementation removes the specified list into the array before moving it and unloads the shuffled array back into the list. This avoids quadratic behavior that would result from shuffling the" sequential access "list.
this is what the java documentation says about the implementation of the Collections.shuffle () method, so passing the java.util.Stack (implementation of the java.util.List interface) should work ...
Thiyagarajan
source share