Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { public static void orderRandom(int upto, int order[]) { Arrays.fill(order, -1); for (int i = 0; i < upto;) { int val = randomInt(upto); if (!intExists(order, val, upto)) { order[i] = val; i++; } } } public static int randomInt(int upto) { int number; number = (int) Math.floor(Math.random() * upto); return number; } private static boolean intExists(int[] vector, int element, int length) { for (int i = 0; i < length; i++) { if (vector[i] == element) { return true; } } return false; } }