For some reason I am having trouble comparing strings when inside a while statement using the using the && and || operators.

while (input.equals("Yes")) && (input.equals("No"))

The error message implies the parentheses are ending the statement prematurely.

Can someone please give me a suggestion?

Thanks,
Jim

Recommended Answers

All 2 Replies

input cannot be "yes" AND be "no" at the same time, so that if test will always be false.

the parentheses are ending the statement prematurely.

Start with the first ( and find its pairing ). Where is that )?
It should be at the end of the conditional expressions used by the while statement.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.