List of utility methods to do Random Number
int | getRandomPortNumber() Returns a random local port number that user applications could bind to. return getRandomPortNumber(MIN_PORT_NUMBER, MAX_PORT_NUMBER);
|
int | getRandonNumber(int range) get Randon Number return randomNumber(range);
|
String | getrannumber() getrannumber StringBuffer strbufguess = new StringBuffer(); String strguess = new String(); int[] nums = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; Random rannum = new Random(); int count; int i = 0, temp_i = 0; for (int j = 10; j > 4; j--) { i = 0; ... |
String | getRndNumByLen(int lengthOfNumber) generate specified length string with numbers. int i, count = 0; StringBuffer randomStr = new StringBuffer(""); Random rnd = new Random(); while (count < lengthOfNumber) { i = Math.abs(rnd.nextInt(9)); if (i == 0 && count == 0) { } else { randomStr.append(String.valueOf(i)); ... |
String | getSerialNumber(int length) get Serial Number StringBuffer stringBuffer = new StringBuffer(); Random random = new Random(); for (int i = 1; i <= length; i++) { stringBuffer.append(random.nextInt(9) + 1); return stringBuffer.toString(); |
String | getTenByteNumber() get Ten Byte Number String tenByte = ""; for (int i = 0; i < 10; i++) { tenByte = tenByte + rd.nextInt(9); return tenByte; |
String | randomHexNumber(final int length) random Hex Number char[] randBuffer = new char[length]; for (int i = 0; i < randBuffer.length; i++) { randBuffer[i] = hexNumbers[randGen.nextInt(15)]; return (new String(randBuffer)); |
String | randomNumber(int length) random Number StringBuffer sb = new StringBuffer(); for (int loop = 0; loop < length; ++loop) { sb.append(digits[rand.nextInt(digits.length)]); return sb.toString(); |
int | randomNumber(int min, int max, Random r) random Number return (int) (r.nextDouble() * (max - min + 1) + min); |
int[] | randperm(int number) randperm int[] array = new int[number]; for (int i = 0; i < number; i++) array[i] = i; int index, temp; Random random = new Random(); for (int i = number; i > 1; i--) { index = random.nextInt(i); temp = array[i - 1]; ... |