shuffle : Java Glossary


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:

Optional Replicator mirror
on local hard disk J:

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.

Your face IP:[]
You are visitor number