随机数生成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-12-26 18:53:04
随机数生成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)); } } }
运行结果如下图: