public class Test {
/**
* (int)(rmd*(max - min + 1) + min) ; [min,max]
*/
public static void main(String[] args) {
new Thread(new Runnable(){
@Override
public void run() {
while(true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
generateNum();
//generateZIMU();
}
}
}).start();
}
// 生成 [1,12]
private static void generateNum() {
double rmd = Math.random();
int num = (int)(rmd*(12-1+1) + 1);
System.out.println(num);
}
// 生成24个小写字母
private static void generateZIMU() {
double rmd = Math.random();
char num = (char)(rmd*('z'-'a'+1) + 'a') ;
System.out.println(num);
}
}