Java tutorial
//package com.java2s; import java.util.HashSet; import java.util.Random; public class Main { public static Integer[] randomIntArray(int size) { Integer a[] = new Integer[size]; HashSet<Integer> set = new HashSet<>(); for (int x = 0; x < a.length; x++) { Random r = new Random(); Integer i = r.nextInt(size * 10); while (set.contains(i)) { i = r.nextInt(size); } set.add(i); a[x] = i; } return a; } }