English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
To convert an integer to a boolean value, first let's initialize an integer.
int val = 100;
Now, we will declare a variable using the original boolean value. When declaring, we will initialize it with the val value and compare it with the integer using the == operator. If the value matches, it returns the value "True", otherwise it returns "False".
boolean bool = (val == 100);
Now let's see the complete example, which shows how to convert an integer to a boolean value.
public class Demo { public static void main(String[] args) { int val = 100; System.out.println("Integer: "+val); boolean bool = (val == 100); System.out.println("Converted to Bool: "+bool); } }
Output Result
Integer: 100 Converted to Bool: true