我工作的while循环,我想停止,而变量是小于100.与我目前的,我的输出停止在128 - 不知道为什么它打印128当最后一次输出应该是64.任何指针?Java虽然循环
import java.util.Scanner;
public class InsectGrowth {
public static void main (String [] args) {
int numInsects = 0;
numInsects = 8;
System.out.print(numInsects + " ");
while (numInsects < 100) {
numInsects = numInsects * 2;
System.out.print(numInsects + " ");
}
System.out.println();
return;
}
}
“**停止**而变量小于100”?然后'while(numInsects> = 100)'。 –
你的意思是“我想在变量小于100时运行*”。 – Mfusiki
当'numInsects'是'64'时是否小于'100'?如果这是真的,循环中会发生什么? – azurefrog