128
Java boolean Keyword
In Java, the boolean keyword is a primitive data type. It is used to store only two possible values, either true or false. It specifies 1-bit of information and its “size” can’t be defined precisely.
The boolean keyword is used with variables and methods. Its default value is false. It is generally associated with conditional statements.
Examples of Java boolean keyword
Example 1: Simple boolean example
Output:
true
Example 2: Comparing the variables of boolean type
Output:
true false false
Example 3: Method of boolean type
Output:
true
Example 4: Comparing objects
Output:
Is objects are equal : false
Example 5: Finding a prime number
Output:
prime
Next TopicJava Byte Keyword