随机数

随机数

代码如下:

package ClassDemo; public class TestRandomCharacter {
public static void main (String[] args) {
final int NUMBER_OF_CHARS = 200;
final int CHARS_PER_LINE =25;

for (int i = 0; i < NUMBER_OF_CHARS; i++) {
char ch = getRandomLetter('A', 'z');
if (0 == (i + 1) % CHARS_PER_LINE) {
System.out.println(ch);
} else {
System.out.print(ch);
}shui
}
} private static char getRandomLetter(char ch1, char ch2) {
return (char) (ch1 + (ch2 - ch1 + 1) * Math.random());
}
}

只相信苦尽甘来
原文地址:https://www.cnblogs.com/F001li/p/7055689.html