一、詳細描述
產生Min-Max之間的數字
二、 實現原理
Math.round(Math.random()*(Max-Min)+Min)
三、 例子說明
隨機生成18到25範圍內的整數
int Temp = (int) Math.round(Math.random() * (25-18) + 18);
System.out.println(Temp);
產生Min-Max之間的數字
Math.round(Math.random()*(Max-Min)+Min)
隨機生成18到25範圍內的整數
int Temp = (int) Math.round(Math.random() * (25-18) + 18);
System.out.println(Temp);