Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Java Boolean operators
There are following boolean operators supported by Java language.
Assume variable A holds 10 and variable B holds 20, then −
| Operator |
Description |
Example |
|---|---|---|
| == (equal to) |
Checks if the values of two operands are equal or not, if yes then condition becomes true. |
(A == B) is not true. |
| != (not equal to) |
Checks if the values of two operands are equal or not, if values are not equal then condition becomes true. |
(A != B) is true. |
| > (greater than) |
Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. |
(A > B) is not true. |
| < (less than) |
Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true. |
(A < B) is true. |
| >= (greater than or equal to) |
Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. |
(A >= B) is not true. |
| <= (less than or equal to) |
Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true. |
(A <= B) is true. |
| && (logical and) |
Called Logical AND operator. If both the operands are non-zero, then the condition becomes true. |
(A && B) is false |
| || (logical or) |
Called Logical OR Operator. If any of the two operands are non-zero, then the condition becomes true. |
(A || B) is true |
! (logical not) |
Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false. |
!(A && B) is true |
Advertisements
