Java xor xor(boolean... bools)

Here you can find the source of xor(boolean... bools)

Description

An xor gate

License

Open Source License

Parameter

Parameter Description
bools Input

Return

Output

Declaration

public static boolean xor(boolean... bools) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from  w  w  w  . jav a  2s.  co  m*/
     * An xor gate
     * @param bools Input
     * @return Output
     */
    public static boolean xor(boolean... bools) {
        boolean didOr = false;
        boolean total = false;
        for (boolean bool : bools) {
            if (total && bool) {
                if (didOr)
                    return false;
            } else {
                total = total || bool;
                didOr = true;
            }
        }
        return total;
    }
}

Related

  1. xor(boolean b1, boolean b2)
  2. xor(boolean b1, boolean b2)
  3. xor(boolean o, boolean t)
  4. xor(boolean val1, boolean val2)
  5. xOr(boolean x, boolean y)
  6. xor(boolean[] array)
  7. xor(boolean[][] b1, boolean[][] b2)
  8. xor(byte abyte0[])
  9. xor(byte data[], byte key[])