【发布时间】:2014-01-17 14:55:11
【问题描述】:
这可能是一个奇怪的问题,但是如果 if 语句的结果为真或假,有没有办法在无限循环中停止扫描程序?
例如,如果您有:
for (;;) {
Scanner in = new Scanner(System.in);
int a = in.nextInt();
if (a <= 0) {
// is there something I could put in here to end the loop?
}
else { System.out.println("Continue"); }
对不起,如果这是一个愚蠢的问题,我对所有这些都是新手。
【问题讨论】: