Java Boolean Data Type

Java Boolean Data Type
The boolean data type in Java is using to store true or false values. It is commonly used in conditions, comparisons, and decision-making.
Boolean Characteristics
| Feature | Details |
|---|---|
| Size | 1 bit (depends on JVM implementation) |
| Values Allowed | true or false |
| Default Value | false |
Example: Simple Boolean Variable
Boolean in Conditions (If Statements)
Boolean values are mostly using in logic and conditions.
Boolean with Comparison Operators
Comparison expressions return boolean results.
Boolean in Logical Operations
Logical operators also work with boolean values.
| Operator | Meaning | Example Result |
|---|---|---|
&& | AND | true && false → false |
| ` | ` | |
! | NOT | !true → false |
Real-Life Example
Output:
Summary
Boolean has only two values:
trueandfalse.Mostly used in decision-making and logical expressions.
Useful with conditions, loops, and comparisons.
