我不明白,为什么下面的代码:Java字符无法正确识别
public Image getLetter(String letterToGet)
{
System.out.println("é" == "e");
System.out.println("Received: " + letterToGet);
if("\u00e9" == letterToGet.toLowerCase()); {
letterToGet = "SPECIALACCTAIGUESPECIAL";
}
if("\u00e8" == letterToGet.toLowerCase()) {
letterToGet = "SPECIALACCTGRAVESPECIAL";
}
System.out.println("searching for " + letterToGet + " in the hashmap");
return languageMap.get(letterToGet.toLowerCase());
}
可以返回输出中
Traduction following ArrayList: [e, é, è]
Received: e
searching for SPECIALACCTAIGUESPECIAL in the hashmap
Received: é
searching for SPECIALACCTAIGUESPECIAL in the hashmap
Received: è
searching for SPECIALACCTAIGUESPECIAL in the hashmap
按照这样的逻辑下,为什么这条线返回false? !
System.out.println("\u00e9" == "e");
可能的重复[如何比较Java中的字符串?](http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) – alfasin