你可以先定义一个大小为10的数组,然后产生10个随机数,进行复制,这些代码都写到一个for循环里面不就搞定了。
先定义数组,然后 Math.random生成随机数,然后通过数组索引赋值给数组对象。for(int i = 1; i < arr.length; i++) { arr[i] = Math.random() * 10;}