shuffle : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

shuffle  shuffle

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.

Learning More

Oracle’s Javadoc on Collections.shuffle : available:

This page is posted
on the web at:

http://mindprod.com/jgloss/shuffle.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\shuffle.html
Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

IP:[65.110.21.43]
Your face IP:[18.188.198.91]
You are visitor number