All Packages  Class Hierarchy  Previous  Next  Index

Shuffling Examples

Shuffling 1 - Shuffling a JGL container.


Shuffling1 Example Code

// Copyright(c) 1996,1997 ObjectSpace, Inc.

import COM.objectspace.jgl.*;

/**
 * Shuffling a JGL container.
 *
 * @see COM.objectspace.jgl.Shuffling
 * @version 2.0.2
 * @author ObjectSpace, Inc.
 */

public class Shuffling1
  {
  public static void main( String[] args )
    {
    Array array = new Array();
    for ( int i = 0; i < 10; i++ )
      array.add( new Integer( i ) );
    System.out.println( "array = " + array );
    Shuffling.randomShuffle( array );
    System.out.println( "after shuffle = " + array );
    }
  }

Shuffling1 Example Output

array = Array( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 )
after shuffle = Array( 2, 7, 9, 0, 6, 5, 3, 4, 1, 8 )

All Packages  Class Hierarchy  Previous  Next  Index