我的if-else用来区分传入的短语是辅音还是元音,如果辅音,它将进一步检查短语结构。但是问题来了
if (first == 'a'|| first == 'e' || first == 'i' || first == 'o' || first == 'u'){
translator.append(phrase).append(sound);
}else{
System.out.println(phrase.substring(0,2));
if(phrase.substring(0,2) == "ch"){
translator.append(phrase.substring(2))
.append(phrase.substring(0,2));
}
}
The word i pass in is 'chair' and I tried to print out the phrase's first 2 words, and have make sure it is 'ch', but the follow if statement
didnt run as expected. What had i did wrong here?
Use
equals