Java 随机数生成器中一个数的计数发生率

Java 随机数生成器中一个数的计数发生率,java,Java,我有一段代码,随机生成从0到9的数字,但我需要计算每个数字弹出的次数 i = new Integer(tTala.getText()).intValue(); n = 1; j = (int)(Math.random() * 10.0); while (n <= i) { j = (int)(Math.random() * 10.0); tTolur.append(""+ j + '\n'); n++; } i=newinteger(tTala.getText()

我有一段代码,随机生成从0到9的数字,但我需要计算每个数字弹出的次数

i = new Integer(tTala.getText()).intValue();
n = 1;
j = (int)(Math.random() * 10.0);
while (n <= i) {
    j = (int)(Math.random() * 10.0);
    tTolur.append(""+ j + '\n');
    n++;
}
i=newinteger(tTala.getText()).intValue();
n=1;
j=(int)(Math.random()*10.0);

而(n您需要的是一个与随机范围大小相同的数组

i = new Integer(tTala.getText()).intValue();
n = 1;
j = (int)(Math.random() * 10.0);
//
int[] tracker = new int[10]
//
while (n <= i) {
    j = (int)(Math.random() * 10.0);
    tTolur.append(""+ j + '\n');
    n++;
    //
    tracker[j]++;
    //
}
i=newinteger(tTala.getText()).intValue();
n=1;
j=(int)(Math.random()*10.0);
//
int[]跟踪器=新的int[10]
//

而(n@GhostCat)我们不再做这种评论了。@mypetlion这并不是那么容易(参见示例)。