Read Java Interview Questions and Answers for Beginners and Experienced

Java Not operator Example

In this Java operator series of Java examples, we will study about Java NOT operator example, we will understand what is the use of java NOT logical operator.


Java Not operator

Java Not Operator is represent as <strong>!</strong>. Java Not operator is used to reverse the value of boolean. if the value is true, It will convert to false. if value is false, it will convert to true.

In Short, Not operator reverse the result evaluated from statement.


Syntax of Java Not Operator

Java Not operator is represented as !. General syntax of Not operator is

! any_statement
  • ! is the Not Operator in Java.
  • any_statement is any variable or any statement evaluated to whom we want to reverse the value.


Java Not operator example

Let’s understand Java Not operator example by taking an example:

public class JavaExamples {

public static void main(String[] args) {
//Java Not operator Example in Java
int a = 10;
int b = 20;
int c = 30;

System.out.println(!((a&amp;lt;b) || (c&amp;gt;b)));
System.out.println(!((a&amp;gt;b) || (c&amp;gt;b)));








For understanding we take same example we did use in Java OR operator example. In both the System.out.println() statement, we just put Not operator which is !. it reverse the output to