标签:col 随机 int public 生成随机数 span 随机数 random system
Math.random() 会得到一个0-1之间的随机浮点数
1 public class HelloWorld { 2 public static void main(String[] args) { 3 int[] a = new int[5]; 4 a[0] = (int) (Math.random() * 100); 5 a[1] = (int) (Math.random() * 100); 6 a[2] = (int) (Math.random() * 100); 7 a[3] = (int) (Math.random() * 100); 8 a[4] = (int) (Math.random() * 100); 9 10 System.out.println("数组中的各个随机数是:"); 11 for (int i = 0; i < a.length; i++) 12 System.out.println(a[i]);
标签:col 随机 int public 生成随机数 span 随机数 random system
原文地址:https://www.cnblogs.com/zhuangbijingdeboke/p/12078187.html