English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
ThisvalueOf()
The method returns a Number object that holds the value of the passed parameter. The parameter can be a primitive data type, String, Boolean, etc. Therefore, to parse a string to a Boolean object, use JavavalueOf()
Method.
The following is an example of how to parse a string to a Boolean object in Java.
public class Demo { public static void main(String[] args) { System.out.println("Parsing a string to a Boolean object..."); Boolean val = Boolean.valueOf("true"); System.out.println("Value: "+val); } }
Output result
Parsing a string to a Boolean object... Value: true
Boolean objects are used to parse the strings in the above program.
Boolean val = Boolean.valueOf("true");
We have passed the string “true” tovalueOf()
The above method. The string is parsed.