Java boolean literals

Introduction

Boolean literals has only two logical values:true and false.

The values of true and false cannot be converted into any numerical representation.

The true literal in Java does not equal 1.

The false literal does not equal 0.

Java Boolean literals can only be assigned to variables declared as boolean or used in expressions with Boolean operators.

The result of the comparison is a Boolean value: true or false.

For example, the following statement displays true:

double radius = 1; 
System.out.println(radius > 0); 

boolean lightsOn = true; 



PreviousNext

Related