《JAVA產生指定範圍的隨機數》
產生機制:
產生Min-Max之間的數字
實現原理:
Math.round(Math.random()*(Max-Min)+Min)
for (int i = 0; i < 10; i++) {
int Temp = (int) Math.round(Math.random() * 7 + 18);
System.out.println(Temp);
}
《JAVA產生指定範圍的隨機數》
產生機制:
產生Min-Max之間的數字
實現原理:
Math.round(Math.random()*(Max-Min)+Min)
for (int i = 0; i < 10; i++) {
int Temp = (int) Math.round(Math.random() * 7 + 18);
System.out.println(Temp);
}