Asked • 03/18/19

Why does this if statement, with an assignment and equality check, evaluate to false?

How does a Java *if statement* work when it has an assignment and an equality check `OR`-d together?? public static void test() { boolean test1 = true; if (test1 = false || test1 == false) { System.out.println("TRUE"); } else { System.out.println("FALSE"); } } Why is this printing FALSE?

2 Answers By Expert Tutors


Patrick B. answered • 06/25/19

4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.