【发布时间】:2018-04-15 15:42:23
【问题描述】:
while 循环在 if 语句中不起作用,为什么它不起作用...以及 while 循环如何在 if 大括号中起作用。
public static void main(String[] args) {
int x = 30;
if (x < 20) {
System.out.print("This is if statement");
int a = 10;
while(a < 20) {
System.out.print("value of x : " + a );
a++;
System.out.print("\n");
}
} else {
System.out.print("This is else statement");
}
}
【问题讨论】:
-
因为30不小于20。
-
感谢我的愚蠢
标签: java if-statement while-loop