随机数生成20~70之间的数值:
public class Random {
public static void main(String[] args) {
java.util.Random r = new java.util.Random();
for (int i = 0; i < 10; i++) {
System.out.print(" " + (r.nextInt(70) + 20));
}
}
}
运行结果如下图:
随机数生成20~70之间的数值:
public class Random {
public static void main(String[] args) {
java.util.Random r = new java.util.Random();
for (int i = 0; i < 10; i++) {
System.out.print(" " + (r.nextInt(70) + 20));
}
}
}
运行结果如下图:
转载于:https://www.cnblogs.com/henuyuxiang/p/3837608.html