English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
To convert a Boolean primitive to a Boolean object, usevalueOf()
Java method.
First, let's take a boolean literal.
boolean val = false;
To convert it to an object, usevalueOf()
method, and set the parameter to a boolean primitive.
Boolean res = Boolean.valueOf(val);
Let's see a complete example to understand how to convert a boolean primitive to a boolean object.
public class Demo { public static void main(String[] args) { boolean val = false; //Convert to Object Boolean res = Boolean.valueOf(val); System.out.println(res); } }
Output Result
False