Boolean.valueOf() String in Java

Boolean.valueOf(): This method is available in the java.lang.Boolean class of Java.

Syntax:

Boolean java.lang.Boolean.valueOf(String s)

This method takes one argument of type String as its parameter. This method returns a Boolean with a value represented by the specified string. The Boolean returned represents a true value if the string argument is not null and is equal, ignoring case, to the string "true".Otherwise, a false value is returned, including for a null argument.

Parameters: One parameter is required for this method.

s: a string.

Returns: the Boolean value represented by the string.

For Example:

Boolean.valueOf("Hello") = > It returns false.

Approach

Java

public class BooleanvalueOfString {
    public static void main(String[] args) {

        String s = "Hello";
        System.out.println(Boolean.valueOf(s));

    }
}

Output:

false

No comments:

Post a Comment