為什么不對呢
package com.Hello;
public class HelloWorld13 {
public static void main(String[] args){
int score = 85;
char sex = "女";
if( score > 80){
if( sex.equals("男")) {
System.out.println("進入男子組決賽");
? ?}else{
? ? System.out.println("進入女子組決賽");
? ?}
??
}else{
? ? System.out.println("淘汰");
}
}
}
2017-09-15
sex == '男' 這樣比較,.equals()方法是String類的方法,而char是字符類型,也就是8大基礎類型中的;同時記得把char sex ='';這樣寫奧
2017-09-13
char sex='女';單引號,String是雙引號,我小白,錯了別噴我