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

Java examples for java.lang:boolean

Description

Performs a XNOR 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(xnor(a, b));
    }/*from   ww  w. j av a2s .co  m*/

    /**
     * Performs a XNOR 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-t;f-f) or false otherwise (t-f;f-t)
     */
    public static boolean xnor(boolean a, boolean b) {
        return !xor(a, b);
    }

    /**
     * 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