Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to write a perfect shuffle method in java

public static int[] RandomizeArray(int[] array){
		Random rgen = new Random();  // Random number generator			
 
		for (int i=0; i<array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
 
		return array;
	}
Source by www.programcreek.com #
 
PREVIOUS NEXT
Tagged: #write #perfect #shuffle #method #java
ADD COMMENT
Topic
Name
6+2 =