English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Creating a Boolean object from a boolean value is very easy. Use Boolean to create an object, and set the boolean value to "true" or "false".
Now let's see how to add the value "True".
Boolean bool = new Boolean("true");
Similarly, add the value "False".
Boolean bool = new Boolean("false");
The following is an example of how to create a Boolean object from a boolean value.
public class Demo { public static void main(String[] args) { Boolean bool = new Boolean("true"); System.out.println(bool); bool = new Boolean("false"); System.out.println(bool); } }
Output Result
True False