February 2014
Beginner
1248 pages
62h 25m
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 one 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 condition ...
Read now
Unlock full access