Java Random Number getRandomNumber(int max, int count)

Here you can find the source of getRandomNumber(int max, int count)

Description

get Random Number

License

Apache License

Declaration

public static Set getRandomNumber(int max, int count) 

Method Source Code

//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;
    }
}

Related

  1. getRandomNumber(int len)
  2. getRandomNumber(int length)
  3. getRandomNumber(int length)
  4. getRandomNumber(int length)
  5. getRandomNumber(int max, boolean include0)
  6. getRandomNumber(int num)
  7. getRandomNumber(int randomCount)
  8. getRandomNumber(int startNumber, int endNumber)
  9. getRandomNumberBetween(int min, int max)