0

I dont know whats wrong with me right now. I dont know if im tired or something but what's wrong with this code

        message = scanner.nextLine();

    while ((!message.equalsIgnoreCase("exit")) || (!message.equalsIgnoreCase("read")))
    {
        System.out.println("WTF");
        Encrypt(message, salt);
        message = scanner.nextLine();
    }

for some reason, even though i for message i write read or exit the program still goes through the loop once ...

0

1 Answer 1

6

You probably meant to use &&:

while ((!message.equalsIgnoreCase("exit")) && (!message.equalsIgnoreCase("read")))

As it is right now, of course the message will not equal one of them. So it loops forever.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.