Here you can find the source of makeListOfIntegersInRange(Integer size, Integer maxOfRange)
public static List<Integer> makeListOfIntegersInRange(Integer size, Integer maxOfRange)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; import java.util.Random; public class Main { public static List<Integer> makeListOfIntegersInRange(Integer size, Integer maxOfRange) { List<Integer> returnVal = new ArrayList<>(); Random random = new Random(27350); while (returnVal.size() < size) { Integer currentVal = random.nextInt(maxOfRange); if (!returnVal.contains(currentVal)) { returnVal.add(currentVal); }//ww w .ja va2s. c om } return returnVal; } }