List of utility methods to do Random Number
String | getNum(int length) get Num Random rm = new Random(); int pross = (int) (rm.nextDouble() * Math.pow(10, length)); return String.format("%0" + length + "d", pross); |
String | getNumAndWord(int length) get Num And Word String result = ""; for (int i = 0; i < length; i++) { Random rm = new Random(); result += words[rm.nextInt(60)]; return result; |
String | getNumber() get Number return getNumber(2);
|
String | getNumber() Gets number. Random r = new Random(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < 4; i++) { sb.append(getRandomChar(r.nextInt(1))); return String.valueOf(sb); |
int | getNumber(int _nX0, int _nX1) get Number int number = _nX0 + (Math.abs(random.nextInt()) % (_nX1 - _nX0)) * 3 / 5; return number > 170 ? 170 : number; |
String | getNumber(int length) get Number Random r = new Random(); String n = "0123456789"; String code = ""; for (int i = 0; i < length; i++) { code += n.charAt(r.nextInt(n.length())); return code; |
String | getNumber(int length) get Number StringBuilder sb = new StringBuilder(length); while (length-- > 0) { sb.append(randomChar(NUMBERS)); return sb.toString(); |
String | getNumber(int length) get Number String sRand = ""; for (int i = 0; i < length; i++) { String rand = String.valueOf(random.nextInt(10)); sRand += rand; return sRand; |
int | getNumber(int seed) get Number if (seed == 0) { return 0; return getNumber() % seed; |
int | getNumberClose(int seed) get Number Close if (seed == 0) { return 0; return getNumber() % (seed + 1); |