Here you can find the source of randIntArray(int length)
public static int[] randIntArray(int length)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; import java.util.Random; public class Main { public static int[] randIntArray(int length) { int array[] = new int[length]; List<Integer> list = new ArrayList<>(); for (int i = 0; i < length; i++) { list.add(i);/*from ww w. ja v a2 s . c o m*/ } Random random = new Random(); for (int i = 0; i < length; i++) { array[i] = list.remove(random.nextInt(length - i)); } return array; } }