這個為什么用char不可以
public class one{
????public static void main(String[] args) {
????????
int score = 95;
???????? char sex = '女';
???????? if (score>80){
???????? if(sex equals("女")){
???????? System.out.println("進(jìn)入女子組決賽");
?????????
}
else{
System.out.println("進(jìn)入男子組決賽");
?????????? }
???????? }
???? }
}
問題在哪?
2017-04-04
char不能和equals()一起用,String可以。Cannot invoke equals(char) on the primitive type char。如下圖:
可以用char,但就不能用equals()了。如下圖:
2017-02-28
equals是判斷字符串變量是否相等的
2017-02-28
就是這一句不對,是為什么