随机数生成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)); } } }
运行结果如下图:
时间: 2024-10-08 00:27:30
随机数生成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)); } } }
运行结果如下图: