Here you can find the source of getRandomNumber(int max, int count)
public static Set getRandomNumber(int max, int count)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static Set getRandomNumber(int max, int count) { Set v = new TreeSet(); Random r = new Random(); boolean b = true; while (b) { v.add(r.nextInt(max));/*from w w w .ja v a 2 s.co m*/ if (v.size() == count) { b = false; } } return v; } }