List of utility methods to do Random Number
Map | createParameters(int numberOfParameters) create Parameters int defaultKeyLength = 8; while (numberOfParameters > Math.pow(ALPHABET.length, defaultKeyLength)) { defaultKeyLength *= 2; Map<String, String> parameters = new HashMap<>(); for (int i = 0; i < numberOfParameters; i++) { parameters.put(generateAlphabetString(defaultKeyLength), generateAlphabetString(defaultKeyLength)); return parameters; |
String | createRandomFilename() create Random Filename return String.valueOf(System.currentTimeMillis());
|
String | createRandomHexNumber(int length) create Random Hex Number Random random = new Random(System.currentTimeMillis()); char[] result = new char[length]; for (int i = 0; i < length; i++) { int r = random.nextInt(16); result[i] = Integer.toHexString(r).charAt(0); return new String(result); |
int | createRandomNumber() create Random Number Random randomGenerator = new Random(); return randomGenerator.nextInt(RANDOM_RANGE); |
int | createRandomNumber(int index) create Random Number int value = (int) (Math.random() * index + 1); return value; |
int[] | distinctInts(int from, int to, int number) Returns from the range of [from, to] (inclusive). if (from >= to) throw new IllegalArgumentException("From cannot be larget than to!"); List<Integer> lst = new ArrayList<Integer>(); for (int i = from; i <= to; i++) lst.add(i); Collections.shuffle(lst, rand); int[] ret = new int[number]; for (int i = 0; i < number; i++) ... |
StringBuffer | generateRandomNum(int i) generate Random Num Random random = new Random(); StringBuffer num = new StringBuffer(); for (int j = 0; j < i; j++) { int numChild = random.nextInt(10); num.append(numChild); return num; |
int | generateRandomNum(int passNumber) generate Random Num int range = passNumber + 1; randomNum = rn.nextInt(range); return randomNum; |
int[] | generateRandomNumb(int randomSize, int range) generate Random Numb int[] randomNumb = new int[randomSize]; for (int i = 0; i < randomSize; i++) { randomNumb[i] = (int) (Math.random() * range) + 1; return randomNumb; |
int | generateRandomNumber() Generate a random number between 5 to 16 Random randomGenerator = new Random(); return randomGenerator.nextInt(11) + 5; |