java

java 亂數

先 import java.lang.Math;

(int)(Math.random()*(需要的數值最大值)+1)
由於隨機亂數是介於 0.0 ~ 0.1 之間的數值,如果不需要從0開始的話,要加「1」