【发布时间】:2021-02-10 08:44:53
【问题描述】:
下面的代码应该生成从 97 到 122 的随机整数:
for(int x = 0; x < 10; x++) {
int a = (int)(Math.random()*(26 + 97));
System.out.println(a);
}
我得到的输出到处都是。他们低于97。 以下是其中一次运行的输出:
33
113
87
73
22
25
118
29
16
21
【问题讨论】:
-
是的,这更像是一道基本的数学题^^
标签: java eclipse random integer