• Post Reply Bookmark Topic Watch Topic
  • New Topic

Collections.shuffle question  RSS feed

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does Collections.shuffle() use java.util.Random either as a default or in general? I know the algorithm is Fisher-Yates shuffle, but what the source of randomness is is important to me for the statistical analysis I am doing. Thanks.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Werner wrote:Does Collections.shuffle() use java.util.Random either as a default or in general? I know the algorithm is Fisher-Yates shuffle, but what the source of randomness is is important to me for the statistical analysis I am doing. Thanks.


You can find the source code in the src.zip file in your JDK installation.
The answer is yes, but note that there is an overloaded version of shuffle that allows you to supply your own class as the source of randomness (as long as it extends Random).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!