Here you can find the source of shuffle(int[] array)
Parameter | Description |
---|---|
array | the array to shuffle |
public static void shuffle(int[] array)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { private final static Random rand = new Random(); /**/*from www. ja va2 s. com*/ * Shuffles the array given. * * @param array the array to shuffle */ public static void shuffle(int[] array) { for (int i = 0; i < array.length - 1; i++) { int j = rand.nextInt(i + 1); int temp = array[j]; array[j] = array[i]; array[i] = temp; } } }