Trace a while loop逐步追踪 while 循环
Run one Java statement or condition check at a time. Watch n and count change.每次执行一条 Java 语句或检查一次条件,观察 n 和 count 的变化。
Code代码
- int n = 20;
- int count = 0;
- while (n > 1) {
- n /= 2;
- count++;
- }
State状态
| Variable变量 | Value值 |
|---|---|
| n | 20 |
| count | 0 |
| Condition条件 | — |
Use ← and → to step. The final condition is false, so the loop stops.使用 ← 和 → 逐步运行。最后条件为假,循环结束。