package com.shrimpking.t3;
import java.util.Random;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/15 15:57
*/
public class ArrayAssignment
{
public static void main(String[] args)
{
//创建随机对象
Random random = new Random();
int[] a = null;
a = new int[random.nextInt(10)];
System.out.println("数组的长度是=" + a.length);
for (int i = 0; i < a.length; i++){
//100以内的随机数
a[i] = random.nextInt(100);
System.out.printf("a[%d] = %d%n",i,a[i]);
}
}
}
标签:Random,ArrayAssignment,int,random,nextInt,public,out
From: https://blog.51cto.com/u_15356972/12097183