Java Boolean Data Type

Java Tutorial

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

FeatureDetails
Size1 bit (depends on JVM implementation)
Values Allowedtrue or false
Default Valuefalse

 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.

OperatorMeaningExample Result
&&ANDtrue && false → false
``
!NOT!true → false

 


 Real-Life Example


 

Output:

Eligible to vote: true

 Summary

  • Boolean has only two values: true and false.

  • Mostly used in decision-making and logical expressions.

  • Useful with conditions, loops, and comparisons.

You may also like...