Following this question: Shuffling numbers in a map and selecting one.
Say you need to select a series of integers randomly from a List
. Could a Collections.shuffle
be considered as equivalent to repeatedly using Random#nextInt
?
I'm not familiar with how shuffle is implemented and whether they could be seen as truly equivalent from a mathematical point of view (permutations). The link below does insist on the importance of using a single Random
object.
http://www.javapractices.com/topic/TopicAction.do?Id=62
P.S: I'm aware that Collections.shuffle
adds an operation in that it actually reorganizes content. It's the result I'm interested in.
Edit: Found this question on SO detailing the shuffle method as using what's called a Fisher-Yates shuffle: Java's Collections.shuffle is doing what?