if嵌套語句
public class HelloWorld {
? ? public static void main(String[] args) {
int score = 94;
String sex = "女";
? ? ? ? if (score>80){
? ? ? ? ? ? //System.out.println("進入決賽"); ? ? ?
? ? ? ? ? ? if(sex){
? ? ? ? ? ? ? ? System.out.println("進入女子組決賽");
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? System.out.println("進入男子組決賽");
? ? ? ? ? ? }
? ? ? ? }
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
}
}
有問題,sex當做條件,錯在哪了
2015-11-15
if 后小括號里必須是一個條件表達式,結果為布爾值:true或者false,sex是個字符串類型,不能當做條件
2015-11-16
非常感謝!