I am trying to create a program that loops through a string, and if it is a vowel that adds it to a variable and then displays. The idea is not to use regular expressions so I use a for. And the problem is that it does not show me the result well, can you help me?
import java.util.Scanner;
import java.lang.StringBuilder;
public class ReemplazarVocales {
public static void main(String[] args) {
Scanner InputText = new Scanner(System.in);
StringBuilder str = new StringBuilder();
System.out.println("Escribe una frase\n");
String Sentence = InputText.next();
Sentence = Sentence.toLowerCase();
char Vocal;
for (int i=0;i <= Sentence.length();i++){
Vocal = Sentence.charAt(i);
String Consonant = Character.toString(Vocal);
if (Consonant != "a" ||Consonant !="e" || Consonant !="i" || Consonant !="o" || Consonant!="u"){
str.append(Consonant);
}
}
System.out.println("\nTu frase sin vocales " + str);
}
}