English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Using thevalueOf()
method to convert a boolean to a boolean. First, let's take a boolean.
boolean val = false;
Now, to convert it to a Boolean object, please usevalueOf()
Method.
Boolean res = Boolean.valueOf(val);
Now let's see the complete example, converting a boolean to a boolean.
public class Demo { public static void main(String[] args) { boolean val = false; System.out.println("Boolean Value = ",+val); Boolean res = Boolean.valueOf(val); System.out.println("Boolean = ", + res); if (res.equals(Boolean.TRUE)) { System.out.println("Boolean = ", + res); } else { System.out.println("Boolean = ", + res); } } }
Output Result
Boolean Value = false Boolean = false Boolean = false