vendredi 1 novembre 2019

How can contentEquals compare multiple strings with all strings matching?

Good morning, The following java code shall compare three strings with requiredProgram and only execute the if-loop and the do-while-loop if requiredProgram does not equal all three strings. It is instead executing the if-loop and the do-while-loop if only one or two of the strings don't match the requiredProgram. How can I program the code to do what I want it to do?

if (!requiredProgram.contentEquals(program1)||
    !requiredProgram.contentEquals(program2)||
    !requiredProgram.contentEquals(program3)) {
        System.out.println("Ohje, das tut mir leid. Hier muss ein Fehler unterlaufen sein! Bitte versuchen sie es erneut.");

    }
    } while(!requiredProgram.contentEquals(program1)||
            !requiredProgram.contentEquals(program2)||
            !requiredProgram.contentEquals(program3));

Aucun commentaire:

Enregistrer un commentaire