Java: get a set of random numbers from a specified range

This is a method that accepts a range (max) and a number (n), returns an array of n random numbers. n: size of random number array max: largest available number (exclusive) For example: Input: n=5, max=100 Output: an array containing 5 random numbers whose range is from 0 to 99. public static HashSet<Integer> getNRandom(int n, … Read more