Java中的多个OR条件

Sha*_*mar 0 java if-statement conditional-statements

为什么这个当前的多条件if语句不能创建没有元音的新字符串?

public class Disemvowel {
    public static void main(String[] args) {
        System.out.println("Please enter a word: ");
        Scanner stdin = new Scanner(System.in);
        String word = stdin.next();
        int wordLength = word.length();
        String disemvoweledWord = "";
        for (int i=0;i<=(wordLength-1);i++){
            char currentLetter = word.charAt(i); 
            System.out.println(currentLetter);
            if (currentLetter!='a' || currentLetter!='e' || currentLetter!='i' || currentLetter!='o' || currentLetter!='u'){
                disemvoweledWord += currentLetter;
            }
        }
        System.out.println(disemvoweledWord);
    }
}
Run Code Online (Sandbox Code Playgroud)

ama*_*ouz 5

你应该对条件进行AND运算而不是ORing.

你只想添加字母,如果它不是'a'而且它不是'e'并且它不是'我'...

要自己查看,请在字母为'a'或'e'时计算布尔表达式的值.