This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.

Originally posted by Jaunty John: These will always resolve false if NOT true

if what not true if: boolean x = true; boolean y = false; boolean z = true; than the first example would be true. and second false. if: boolean x = false; boolean y = false; boolean z = true; the the first is false and the second is true.

Roger Sanchez
Greenhorn

Joined: Jun 23, 2003
Posts: 16

posted

0

I forgot to put the variable values: x = false, y = true, z = false ( ( x || ! ( y && z ) ) && ! ( y || z) )

x = false, y = true, z = false ( ( ! x && ( y || z ) ) || ( ! y || z)) Thanks again

They might be trying to simplify the equation. For example, take this one: ( ( x || ! ( y && z ) ) && ! ( y || z) ) If either y or z is true, this statement is false (because the right side of the *AND is false). So, plug false values for y and z into the left expression, getting (x || true), which removes x from the equation. The whole thing factors downs to (!y && !z). Similarly, after some careful manipulation, the second statement is (!x || !y || z). Don't believe me? You could always try a truth table <grin>. Joe

Roger Sanchez
Greenhorn

Joined: Jun 23, 2003
Posts: 16

posted

0

Thanks for the quick reply. So, to check my understanding, both statements are false?

Joe Pluta
Ranch Hand

Joined: Jun 23, 2003
Posts: 1376

posted

0

Nope. First is false, second is true. Quick runthrough: x = false, y = true, z = false ( ( x || ! ( y && z ) ) && ! ( y || z) ) ( ( F || ! ( T && F ) ) && ! ( T || F ) ) ( ( F || ! ( F ) ) && ! ( T ) ) ( ( F || T ) && F ) ( T && F ) F x = false, y = true, z = false ( ( ! x && ( y || z ) ) || ( ! y || z)) ( ( ! F && ( T || F ) ) || ( ! T || F ) ) ( ( T && T ) || ( F || F ) ) ( T || F) T