new Random().nextInt(100) +1;//不加1 则得到的是 0——99之间的随机数 加 1 则得到的时1——100之间的随机数
java里面产生1-100随机数都有哪些方法?
public class Test { public static void main(String[] args) { int i = (int)(Math.random()*100); System.out.println(i); } }2014-06-28
Random random = new Random(System.currentTimeMillis()); int iRandom = random.nextInt(100)+1;2014-06-28
new Random().nextInt(100) +1;//不加1 则得到的是 0——99之间的随机数 加 1 则得到的时1——100之间的随机数2015-09-27