random.nextInt(33) 随机产生一个大于等于0,小于33的整数
示例: 双色球 twocolorball.groovy
import java.util.Random;
int a =0;
int b =0;
def random = new Random();
def reds = [];
while(reds.size() <6){
a = random.nextInt(33)+1;
if(! reds.contains(a)) reds.add(a);
}
println "红球: ${reds.sort()}"
b = random.nextInt(16)+1;
println "蓝球: ${b}"
运行 groovy twocolorball