List of utility methods to do Random
String | generateRandomNo() It generates a random number and returns it as string. int id = 0; int range = Integer.MAX_VALUE / 3 * 2; Random rand = new Random(); for (int i = 0; i < 1000; i++) { id = rand.nextInt(range); return Integer.toString(id); |
int | GenerateRandomPin() Generate Random Pin int t = 0; Random random = new Random(); for (int i = 0; i < MaxPinLength - 1; i++) { t += random.nextInt(9); t *= 10; return t; |
int | getItemID(Random r) get Item ID return nonUniformRandom(8191, 1, 100000, r);
|
int | getOreMultiplier(int fortune, Random r) get Ore Multiplier switch (fortune) { case 1: return r.nextInt(3) == 0 ? 2 : 1; case 2: switch (r.nextInt(4)) { case 0: return 2; case 1: ... |
int | getPoisson(double lambda, Random rng) Poisson-distributed RNG double L = Math.exp(-lambda); double p = 1.0; int k = 0; if (rng == null) rng = new Random(); do { k++; p *= rng.nextDouble(); ... |
Random | getRandom() get Random if (random == null) { random = new Random(); random.setSeed(System.currentTimeMillis()); return random; |
Random | getRandom() get Random return random;
|
Random | getRandom() get Random if (random != null) return random; else return getRandom(System.currentTimeMillis()); |
T | getRandom(Collection get Random if (collection.isEmpty()) return null; int randomIndex = rnd.nextInt(collection.size()); int i = 0; for (T obj : collection) { if (i == randomIndex) return obj; i = i + 1; ... |
String | getRandom(int i) get Random Random jjj = new Random(); if (i == 0) return ""; String jj = ""; for (int k = 0; k < i; k++) { jj = jj + jjj.nextInt(9); return jj; ... |