List of utility methods to do Random Number
String | generateRandomnumber(int firstNum, int restNum) generate Randomnumber Random random = new Random(System.currentTimeMillis()); String first = String.valueOf(random.nextInt(firstNum)); String rest = String.valueOf(random.nextInt(restNum)); return first + rest; |
int | generateRandomNumber(int from, int to) Generates random number in given range. return r.nextInt(to - from + 1) + from;
|
String | generateRandomNumber(int length) generate Random Number Random random = new Random(); String val = ""; for (int i = 0; i < length; i++) { val += String.valueOf(random.nextInt(10)); return val; |
int | generateRandomNumber(int min, int max) generate Random Number return (int) (min + (Math.random() * ((max - min) + 1))); |
int | generateRandomNumber(int min, int max) Generates a random number in the range [min, max] return min + (int) (Math.random() * ((max - min) + 1)); |
int | generateRandomNumber(int start, int end) Generates the random number within the range. double randomValue = Math.random(); int randomNumber = (int) (start + Math.round(randomValue * (end - start))); return randomNumber; |
int | generateRandomNumberBetween(final int low, final int high) generate Random Number Between return low + new Random().nextInt(high - low); |
String | generateRandomNumericString(int maxLength) generate Random Numeric String Random random = new Random(); Long number = new Long((Math.round(Math.random() * maxLength))); return number.toString(); |
String | generateSaltNumber() generate Salt Number Random random = new Random(System.nanoTime()); StringBuilder saltNumber = new StringBuilder(); for (byte i = 0; i < SALT_NUMBER_SIZE; i++) { saltNumber.append(random.nextInt(10)); return saltNumber.toString(); |
String | genRandomNum(int pwd_len) gen Random Num final int maxNum = 36; int i; int count = 0; char[] str = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; StringBuffer pwd = new StringBuffer(""); Random r = new Random(); while (count < pwd_len) { i = Math.abs(r.nextInt(maxNum)); ... |