// ShuffleTest.java
// Using algorithm shuffle.
package chapter36;

import java.util.List;
import java.util.Arrays;
import java.util.Collections;

public class ShuffleTest
{
    private static final String suits[] =
            { "Hearts", "Diamonds", "Clubs", "Spades" };

    // output List elements
    public void printElements()
    {
        List< String > list = Arrays.asList( suits ); // create List

        // output List elements
        System.out.printf( "Array elements:\n%s\n", list );

        // Use method shuffle of class Collections to shuffle List
        Collections.shuffle( list );  // shuffle deck

        // output List elements
        System.out.printf( "Shuffled list elements:\n%s\n", list );
    } // end method printElements

    public static void main( String args[] )
    {
        ShuffleTest shuffleTest = new ShuffleTest();
        shuffleTest.printElements();
    } // end main
} // end class ShuffleTest
