package com.shrimpking.t16;
import java.util.ArrayList;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/11/9 20:54
*/
public class MyTest3
{
public static void main(String[] args)
{
ArrayList<Integer> al = new ArrayList<>();
while (al.size() < 1000){
int value = (int)(Math.random() * 2000); //2000以内随机一个数
boolean b = true;
for (Integer v : al)
{
if (value == v){
b = false; //已经有个数,就标记
break;
}
}
if (b){
al.add(value); //不重复,就添加
}
}
int count = 0;
for (Integer v : al)
{
System.out.printf("%-4d\t",v);
count++;
if (count > 10){
System.out.println(); //换行
count = 0;
}
}
}
}
标签:count,int,ArrayList,al,value,2000,MyTest3
From: https://blog.csdn.net/modern358/article/details/143651197