Performs a XOR boolean operation between the two boolean objects passed as parameter. - Java java.lang

Java examples for java.lang:boolean

Description

Performs a XOR boolean operation between the two boolean objects passed as parameter.

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        boolean a = true;
        boolean b = true;
        System.out.println(xor(a, b));
    }//from  w w w.j a  va 2s. c om

    /**
     * Performs a XOR boolean operation between the two boolean objects passed as parameter.
     *
     * @param a the first boolean
     * @param b the second boolean
     * @return True if the XOR operation returns true (t-f;f-t) or false otherwise (t-t;f-f)
     */
    public static boolean xor(boolean a, boolean b) {
        return a ^ b;
    }
}

Related Tutorials