1
Context: I’m making an algorithm that stores random strings typed by the user in a string array until the user type "stop".
problem: when typing stop, the eclipse continues the loop in while, and in if (wordDigited != "stop"), even if the wordDigited == stop it keeps entering that if.
code:
while (palavraDigitada != "parar") {
        System.out.print("Escreva quaisquer string ou digite parar para buscar: ");         
        palavraDigitada = tec.next();
        if (palavraDigitada != "parar") {
            if (palavrasEmLista == "") {
                palavrasEmLista = palavraDigitada;
            }
            else {
                palavrasEmLista = palavrasEmLista + ";" + palavraDigitada;
            }               
            contador++;
        }
    }
Do not use
==or!=to compareStrings. Use the methodequals. See the linked question to understand why.– Victor Stafusa