【发布时间】:2017-01-08 08:43:50
【问题描述】:
我正在生成 2 个生成的整数,然后我将它们分开。我想检查 2 个除整数的结果是整数还是小数。然后我将尝试比较结果并将结果与带有此代码的字符串进行整数化,但它停止工作。
Random r = new Random();
int first = r.nextInt(50 - 1) + 1;
Random z = new Random();
int twond = z.nextInt(50 - 1) + 1;
float Resultas = (first / twond);
Result = (int) Resultas;
String floatResult = Float.toString(Resultas);
while (floatResult != String.valueOf(Result)) {
Random s = new Random();
first = s.nextInt(50 - 1) + 1;
Random y = new Random();
twond = y.nextInt(50 - 1) + 1;
Resultas = (first / twond);
Result = (int) Resultas;
floatResult = Float.toString(Resultas);
}
【问题讨论】:
-
使用TypeVariable..
-
为什么停止代码工作。给它一个例外,您可以将其添加到您的问题中吗?请阅读how to ask。
-
H. Pauwelyn 我不明白你在说什么。
标签: android math int operators