Java Random Int randProductNumerid(final int c, final int count)

Here you can find the source of randProductNumerid(final int c, final int count)

Description

rand Product Numerid

License

Open Source License

Declaration

public static int[] randProductNumerid(final int c, final int count) 

Method Source Code

//package com.java2s;

public class Main {

    public static int[] randProductNumerid(final int c, final int count) {
        int ret[] = new int[c];
        int i = 0;
        while (true) {
            if (i == c) {
                break;
            }/*from   w w w  .j  a  v  a  2s .c om*/
            int a = (int) Math.ceil(Math.random() * count);
            if (!isExist(a, ret)) {
                ret[i++] = a;
            }
        }
        return ret;

    }

    private static boolean isExist(final int a, final int[] ints) {
        boolean ret = false;
        for (int i = 0; i < ints.length; i++) {
            if (a == ints[i]) {
                ret = true;
                break;
            }
        }
        return ret;
    }
}

Related

  1. randomWithinRange(int min, int max)
  2. randomWithRange(int min, int max)
  3. randomWord(int wordLength)
  4. randomZeroString(int length)
  5. randowPartition(int[] array, int q, int p)
  6. RandSelect(int iTotal)