# 066 TestIfElse2.java package ch04; /* * 此範例說明Nested if - else流程觀念 * 另使用equals進行比對字串示範 */ public class TestIfElse2 { int age = 29; String sex = "女"; // "男" if (age <= 29) if (sex.equals("女")) System.out.println("我請妳看電影^_^"); else System.out.println("謝謝再聯絡!"); else System.out.println("謝謝再聯絡!"); --- //可以改成以下寫法 if (age <= 29 && sex.equals("女")) System.out.println("我請妳看電影^_^"); else System.out.println("謝謝再聯絡!"); } }
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up