88
Java Boolean parseBoolean() Method
The parseBoolean() method of Boolean class returns the string argument as a Boolean. The value is returned true if the argument is equal to the string “true” otherwise, for null or any other string argument, it returns false.
Syntax:
Parameters:
A String parameter s is passed.
Return Value:
The logicalXor() method returns the Boolean represented by the string argument.
- It returns true, if the string argument is not null and is equal (ignoring case) to the string “true”.
- It returns false for null for any other argument other than true.
Example 1
Output:
String value = false String hash code value = 97196323 Boolean value = false Boolean hash code value = 1237
Example 2
Output:
True/False: Q. Tal Mahal is located in Delhi. Ans true 1231 Incorrect. Because Taj Mahal is located in Agra.
Example 3
Output:
Enter any String value : reema Boolean value is false.
For any String other than true, parseBoolean() method will return false.
Next TopicJava Boolean