No. In this defective fragment, the NOT (the !) applies directly to cost
.
The NOT operator has high precedence, so it is done before arithmetic and relational operators unless you use parentheses. Examine the following:
!cost < 50 ----- illegal: can't use ! on an arithmetic variable
Since !
has high precedence,
the above says to apply it to
cost
.
This which won't work, because cost
is an integer and
NOT applies only to boolean values.
Look at this fragment:
if ( cost < 50 ) System.out.println("Acceptable shoes"); else System.out.println("Reject these shoes");
Is the new fragment equivalent to the original fragment:
if ( !(cost < 50) ) System.out.println("Reject these shoes"); else System.out.println("Acceptable shoes");
Try a few trial costs with each fragment to see if they are equivalent.