Question: 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);

    }
}

```

Answer: 
There seem to be three problem in you code:

1. you are looping from index int i=0 till i=length, which will give you IndexOutOfBound.

Since string indexing start from 0 you can loop like

```
for (int i=0;i < Sentence.length();i++){

            Vocal = Sentence.charAt(i);
            String VocalP = Character.toString(Vocal);

            if (!VocalP.equals("a") && !VocalP.equals("e") && !VocalP.equals("i") && !VocalP.equals("o") && !VocalP.equals("u")){
                str.append(VocalP);
            }
        }

```

2. you need to have (&&) instead of Logical (||) because you wish to eliminate all the vowels.
3. It is adviceable to do string comparision using equals or equalsIgnoreCase to compare two strings
You wrote:

```
if (VocalP!="a" || VocalP!="e" || VocalP!="i" || VocalP!="o" || VocalP!="u")

```

which if you look closely will always be true.
for example if you take the first two options only:

```
if (VocalP!="a" || VocalP!="e")

```

if the letter is not 'a' OR the letter is not 'b'

and the letter is 'a' it will still evaluate to true because it is not 'e'
from your question you should be using == instead of !=
so try:

```
if (VocalP=="a" || VocalP=="e" || VocalP=="i" || VocalP=="o" || VocalP=="u")

```