考慮這個代碼示例。我怎麼能出來如果塊?
此代碼只是爲了解釋我的問題。
boolean status = false;
for (int i = 0; i <= 5; i++) {
if (i == 4) {
System.out.println ("Enter into first if");
if (status == false) {
System.out.println ("Enter into second if");
status = true;
if (status == true) {
System.out.println ("Enter into third if");
//third if body
}
//second if body
}
//first if body
System.out.println ("Before exiting first if");
}
}
所有我想要做的是從第三齣來,如果首先如果。
我們知道休息,繼續是可以在環使用那裏。我們可以達到相同的塊?
爲什麼不只是改變if語句呢? –
重構你的代碼。 – Schaliasos
現在還不清楚你試圖達到什麼目標。在這種情況下,不要問如何逃避if,查看實際問題並重構代碼以滿足您的需求。 –