我只是想知道,如果運行一半的'if'語句在它不得不滿足的條件時會停止運行。這很難用文字來解釋,這裏是一個例子:如果語句中斷可以中斷嗎?
boolean flag = true;
if(flag){
//Some code execution here (code execution #1)
flag = false;
//Some more code execution here (code execution #2)
}
在這種情況下運行「代碼執行#2」嗎?或者當flag設置爲false時,會跳過if語句的其餘部分嗎?
是的,它會運行;該檢查只發生一次。你試過了嗎? – Ryan 2015-04-01 01:33:25
你可以使用「break」 – mastrgamr 2015-04-01 01:33:37
這是什麼功能。 – Qix 2015-04-01 01:34:21