Date: Fri, 21 May 2004 13:54:27 -0400 From: chris rued <cbr@michaelpee.homeip.net> To: Thorsten Greiner <thorsten@tgreiner.net> Cc: java@freebsd.org Subject: Re: EX-OR Boolean Operator in Java Message-ID: <40AE4253.20102@michaelpee.homeip.net> In-Reply-To: <20040521164036.GA782@tybalt.greiner.local> References: <7FF62A49079FD511B14400065B19EF120550B8A0@cprnt003.satyam.com> <40AE1884.3090206@xsb.com> <20040521164036.GA782@tybalt.greiner.local>
next in thread | previous in thread | raw e-mail | index | archive | help
Thorsten Greiner wrote: >* Christopher Rued <c.rued@xsb.com> [2004-05-21 18:31]: >> (a && !b) || (!a && b). >> There is no XOR boolean operator in Java, AFAIK. > >Come on guys, think before you hit that send button: the boolean >operators in Java are: > > ! NOT > & AND > | OR > ^ XOR > >There are two short-ciruit operators: > > && AND > || OR > >These do not evaluate their right hand side expression if the left >side is either false (&&) or true (||). You actually should find > >that in any entry level book on Java programming. > I stand corrected. As Thorsten ever so politely pointed out, a ^ b works just fine, and is logically equivalent to my original suggestion. I knew of & and | as the non-short-circuit versions of && and ||, but I didn't know that ^ was a valid operator on booleans. I only knew of ^ as a bit-wise operator on numerical primitives before. --Chris
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40AE4253.20102>