條件成立執行 if 塊,否則執行 else 塊。兩者必執行其一。
if (條件) { // 成立代碼 } else { // 不成立代碼 }
int score = 95; if (score > 90) { System.out.println("獎勵 iPhone 5S"); } else { System.out.println("罰 500 個俯臥撐"); }