Here you can find the source of randperm(int number)
public static int[] randperm(int number)
//package com.java2s; //License from project: Apache License import java.util.Random; public class Main { public static int[] randperm(int number) { int[] array = new int[number]; for (int i = 0; i < number; i++) array[i] = i;// ww w . j a va 2 s.c o m int index, temp; Random random = new Random(); for (int i = number; i > 1; i--) { index = random.nextInt(i); temp = array[i - 1]; array[i - 1] = array[index]; array[index] = temp; } return array; } }