int x = 1;
int result = 3;
while ( x < 5 ) {
result = result + 2;
x = x + 1;
}
使用 Java 进行处理
预测最终结果将是 9,而不是最终结果是 11。不知道如何,因为当结果等于 11 x 等于 5 时,这将打破循环并使用结果的先前值。
x = 1 < 5 => result = result + 2 = 5
x = 2 < 5 => result = result + 2 = 7
x = 3 < 5 => result = result + 2 = 9
x = 4 < 5 => result = result + 2 = 11
x = 5 = 5 => break because 5<5 is not true