List of utility methods to do Random Int
int | random_range(int x1, int x2) Returns a random real number between x1 (inclusive) and x2 (exclusive). return (int) (Math.floor(x1 + (Math.random() * (x2 - x1)))); |
int | randomActorId(int max) random Actor Id int min = 0; return randomNumber(min, max); |
String | randomAlphaNum(int length) Generates random alphanumeric String of the specified length. char[] result = new char[length]; fillWithRandomAlphaNum(result); return new String(result); |
String | randomAlphanumeric(int count) random Alphanumeric char[] chars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; StringBuilder res = new StringBuilder(); for (int i = 0; i < count; i++) { res.append(chars[(int) (chars.length * Math.random())]); return res.toString(); |
String | randomAlphanumericString(int length) random Alphanumeric String String set = "abcdefghijklmnopqrstuwxyz0123456789"; StringBuilder builder = new StringBuilder(); for (int i = 0; i < length; i++) { builder.append(set.charAt(randomNumber(0, set.length()))); return builder.toString(); |
String | randomAlphaString(int length) random Alpha String StringBuilder builder = new StringBuilder(length); for (int i = 0; i < length; i++) { char c = (char) (65 + 25 * Math.random()); builder.append(c); return builder.toString(); |
double[] | randomArray(int len) random Array double[] data = new double[len]; for (int i = 0; i < len; i++) { data[i] = 0; return data; |
int[] | randomArray(int min, int max, int n) Generate n random and different numbers within specified non-negative integer range if (n > (max - min + 1) || max < min || min < 0 || max < 0) { return null; int[] result = new int[n]; for (int i = 0; i < n; i++) { result[i] = -1; int count = 0; ... |
String | randomBases(int n) Generate a string of random bases of length n. StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { int pick = (int) Math.floor(Math.random()); switch (pick % 4) { case 0: sb.append("T"); break; case 1: ... |
void | randomBlock(byte[] block, int off, int len) random Block for (int i = off; i < off + len; ++i) block[i] = (byte) (Math.random() * 256.0); |