mercredi 25 février 2015

Multiple OR conditions in Java

Why doesn't this current multiple conditional if-statement work to create a new string without the vowels?



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);
}
}

Aucun commentaire:

Enregistrer un commentaire