Boolean.logicalXor() in Java

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

Syntax:

boolean java.lang.Boolean.logicalXor(boolean a, boolean b)

This method takes two arguments of type boolean as its parameters. This method returns the result of applying the logical XOR operator to the specified boolean operands.

Parameters: Two parameters are required for this method.

a: the first operand.

b: the second operand.

Returns: the logical XOR of a and b.

For Example:

Boolean.logicalXor(true,false) = > It returns true. 

Approach

Java

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

        boolean a = true, b = false;
        System.out.println(Boolean.logicalXor(a, b));

    }
}

Output:

true

No comments:

Post a Comment