Java xor xor(boolean a, boolean b)

Here you can find the source of xor(boolean a, boolean b)

Description

Perform an either/or operator

License

Open Source License

Parameter

Parameter Description
a a parameter
b a parameter

Return

true if one or the other is true but not both

Declaration

public static boolean xor(boolean a, boolean b) 

Method Source Code

//package com.java2s;
/*----------------------------------------------------------------------------- 
 * GDSC SMLM Software/*from ww  w  .  j  a  va2 s.co m*/
 * 
 * Copyright (C) 2016 Alex Herbert
 * Genome Damage and Stability Centre
 * University of Sussex, UK
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *---------------------------------------------------------------------------*/

public class Main {
    /**
     * Perform an either/or operator
     * 
     * @param a
     * @param b
     * @return true if one or the other is true but not both
     */
    public static boolean xor(boolean a, boolean b) {
        return (a && !b) || (b && !a);
    }
}

Related

  1. xor(boolean a[], boolean b[])
  2. xor(boolean b1, boolean b2)
  3. xor(boolean b1, boolean b2)
  4. xor(boolean o, boolean t)