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 build simple search page using ZK and Spring Boot? - March 8, 2023
- How do I calculate days between two dates excluding weekends and holidays? - January 12, 2023
- How do I discover the quarter of a given date? - January 11, 2023