Here you can find the source of xor(boolean... bools)
Parameter | Description |
---|---|
bools | Input |
public static boolean xor(boolean... bools)
//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; } }