Where you need to simulate the shuffling of a deck of cards, i.e. putting them in order by a random permutation, use java.util.Collections.shuffle(). Even though it is a method in Collections, it only works on Lists, though will work on Lists without RandomAccess. There is also Shuffle class for shuffling int[] or Object[] included in com.mindprod.common18. Unfortunately, there is no java.util.Arrays.shuffle() method. You have to convert an array to an java.util.ArrayList, (or other java.util.List), shuffle, then convert back.
This page is posted |
http://mindprod.com/jgloss/shuffle.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\shuffle.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[3.135.216.196] |
| |
Feedback |
You are visitor number | |