import java.util.Random;
public class Main {
public static void main(String args[]){
//创建随机数
Random random = new Random();
//创建一个int类型数组,数组名为arr,数组长度为20
int[] arr = new int[20];
//遍历数组,将数组中的每一个元素替换为随机数
for (int i = 0; i < 20; i++) {
arr[i] = random.nextInt(10);
System.out.print(arr[i] + ",");
}
System.out.println(); //换行
//定义数字x,和x在数组中出现的次数sumber
for (int x = 0; x < 10; x++) {
int sumber = 0;
//遍历数组arr
for (int j = 0; j < 20; j++) {
//数组中的数循环比较
if (x == arr[j]) {
sumber++;
}
else {
continue;
}
}
System.out.println(x + "重复的个数为" + sumber);
}
}
}