大家帮帮忙,能不能稍微改的简介一些,总感觉判断的环节还可以再方便点.....求相助
获取随机0~9之间的数,显示每个数的出现次数public class zuoye
{
public static void main(String[] args) {
int[] ch = new int[100];
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0;
for(int i = 0; i<ch.length; i++){
ch[i] = (int)(Math.random() * 10);
}
for(int i = 0; i<ch.length; i++){
if(ch[i] == 0){
a++;
}
if(ch[i] == 1){
b++;
}
if(ch[i] == 2){
c++;
}
if(ch[i] == 3){
d++;
}
if(ch[i] == 4){
e++;
}
if(ch[i] == 5){
f++;
}
if(ch[i] == 6){
g++;
}
if(ch[i] == 7){
h++;
}
if(ch[i] == 8){
j++;
}
if(ch[i] == 9){
k++;
}
}
System.out.println("0出现" + a +"次");
System.out.println("1出现" + b +"次");
System.out.println("2出现" + c +"次");
System.out.println("3出现" + d +"次");
System.out.println("4出现" + e +"次");
System.out.println("5出现" + f +"次");
System.out.println("6出现" + g +"次");
System.out.println("7出现" + h +"次");
System.out.println("8出现" + j +"次");
System.out.println("9出现" + k +"次");
}
}