long to boolean Java

long to boolean Java


After knowing primitive data types and Java rules of Data Type Casting (Type Conversion), let us cast long to boolean as an example.

The data type boolean is incompatible for converting into any other data type. That is, a boolean value cannot be converted (or assigned to) into any other data type like char, int, double, long etc. The maximum permitted is one boolean can be assigned to another boolean.

Following are not permitted.

Following is permitted (boolean assignment).

The keyword boolean is used in comparison operations.

Let us write a simple example to see how compiler react with boolean casting with long to boolean.


long to boolean
Error message screenshot of long to boolean Java

View all for 65 types of Conversions

Leave a Reply

Your email address will not be published. Required fields are marked *