对数组随机赋值,并输出(Arrays.toString(arr))

import java.util.Arrays;

public class Demo {
    public static void main(String[] args) {
        int[] arr = new int[10];
        for (int i=0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * 100);
        }
        System.out.println(Arrays.toString(arr));
    }
}
运行结果:
[48, 31, 63, 67, 77, 80, 58, 52, 47, 61]
原文地址:https://www.cnblogs.com/1020182600HENG/p/5868313.html