List of utility methods to do Random Number
String | getRandomNumber(int randomCount) get Random Number Random random = new Random(); StringBuilder sb = new StringBuilder(randomCount); for (int i = 0; i < randomCount; i++) sb.append((char) ('0' + random.nextInt(10))); return sb.toString(); |
int | getRandomNumber(int startNumber, int endNumber) get Random Number Random randomGenerator = new Random(); long range = (long) startNumber - (long) endNumber + 1; long fraction = (long) (range * randomGenerator.nextDouble()); int randomNumber = (int) (fraction + startNumber); return (Math.abs(randomNumber) == 0) ? getRandomNumber(startNumber, endNumber) : Math.abs(randomNumber); |
int | getRandomNumberBetween(int min, int max) Returns a random int between min and max, inclusive. return useRandomForNumberBetween(rand, min, max);
|
long | getRandomNumberFixLength() get Random Number Fix Length return 1000000000L + generator.nextInt(2000000000);
|
Random | getRandomNumberGenerator() get Random Number Generator return new Random(++seedQualifier + System.nanoTime()); |
int | getRandomNumberInRange(Random random, int min, int max) Returns a random number between min and max, inclusive. return min + random.nextInt(max - min + 1);
|
ArrayList | getRandomNumbers(int range, int count, Random rnd) get Random Numbers if (count > range) { return null; if (count < 0 || range < 0) { return null; ArrayList<Integer> indices = new ArrayList<Integer>(); if (count < range / 2) { ... |
String | getRandomNumberString(int length) get Random Number String Random rand = new Random(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < length; i++) { int pos = rand.nextInt(NUMBERS.length()); sb.append(NUMBERS.charAt(pos)); return sb.toString(); |
String | getRandomNumer(int length) get Random Numer if (length > 9 || length < 1) { return null; int maxNum = (int) Math.pow(10, length); Random random = new Random(System.currentTimeMillis()); int code = random.nextInt(maxNum - 1); return String.format("%0" + length + "d", code); |
String | getRandomNumericString(int maxlen) get Random Numeric String String str = new String(); for (int j = 0, n = R.nextInt(maxlen) + 1; j < n; ++j) { str += (char) ('0' + R.nextInt(10)); return str; |