January 2014
Intermediate to advanced
736 pages
70h 43m
English
The ! (logical NOT, also called logical negation or logical complement) operator “reverses” the meaning of a condition. Unlike the logical operators &&, ||, &, | and ^, which are binary operators that combine two conditions, the logical negation operator is a unary operator that has only a single condition as an operand. The operator is placed before a condition to choose a path of execution if the original condition (without the logical negation operator) is false, as in the program segment
if ( ! ( grade == sentinelValue ) ) System.out.printf( "The next grade is %d\n", grade );
which executes the printf call only if grade is not equal to sentinelValue. The parentheses around the ...
Read now
Unlock full access