Skip to content
This repository was archived by the owner on Feb 27, 2026. It is now read-only.

Commit 0ca025d

Browse files
Add Logical Operators with examples to operators.md (#7675)
* Keep only Logical Operators section in operators.md * minor fixes ---------
1 parent 2189f81 commit 0ca025d

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

content/java/concepts/operators/operators.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,23 @@ int bitwiseRightShift = a >> b;
107107
int bitwiseLeftShift = a << b;
108108
// 40
109109
```
110+
111+
## Logical Operators
112+
113+
Logical operators combine multiple boolean expressions or values. They return a boolean result (`true` or `false`).
114+
115+
These are the logical operators in Java:
116+
117+
- `&&` Logical AND: Returns true if **both** expressions are `true`.
118+
- `||` Logical OR: Returns true if **any** expression is `true`.
119+
- `!` Logical NOT: Reverses the result (`true``false`).
120+
121+
```java
122+
int a = 10;
123+
int b = 5;
124+
int c = 20;
125+
126+
System.out.println((a > b) && (a < c)); // true, both conditions are true
127+
System.out.println((a > b) || (a > c)); // true, one condition is true
128+
System.out.println(!(a > b)); // false, negates true
129+
```

0 commit comments

Comments
 (0)