3.7 巢狀 if 與大括號省略的陷阱
有時候,我們需要在一個 if 分支裡再檢查另一個條件。這就是巢狀 if。
¶巢狀 if 的語法
if (條件1) {
if (條件2) {
// 條件1 和 條件2 都為 true 時執行
} else {
// 條件1 為 true,條件2 為 false 時執行
}
} else {
// 條件1 為 false 時執行
}
¶帳號對了才檢查密碼
Log in to read the full content
The syntax book is free for every AACPOJ account. Signing up takes a minute.