The !
operator is a logical compliment operator. The operator inverts the value of a boolean
expression.
package org.kodejava.basic;
public class NegationOperator {
public static void main(String[] args) {
// negate the result of boolean expressions
boolean negate = !(2 < 3);
boolean value = !false;
System.out.println("result: " + negate);
System.out.println("value : " + value);
}
}
Here is the result of the program:
result: false
value : true
Latest posts by Wayan (see all)
- How do I get number of each day for a certain month in Java? - September 8, 2024
- How do I get operating system process information using ProcessHandle? - July 22, 2024
- How do I sum a BigDecimal property of a list of objects using Java Stream API? - July 22, 2024