From owner-freebsd-java@FreeBSD.ORG Fri May 21 10:54:31 2004 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E3B9416A4CE for ; Fri, 21 May 2004 10:54:31 -0700 (PDT) Received: from xsb.com (mail.portjeff.net [216.168.142.132]) by mx1.FreeBSD.org (Postfix) with ESMTP id 821FA43D31 for ; Fri, 21 May 2004 10:54:31 -0700 (PDT) (envelope-from cbr@michaelpee.homeip.net) Received: from michaelpee.homeip.net [129.49.16.170] by xsb.com with ESMTP (SMTPD32-7.15) id A1451E30090; Fri, 21 May 2004 13:49:57 -0400 Message-ID: <40AE4253.20102@michaelpee.homeip.net> Date: Fri, 21 May 2004 13:54:27 -0400 From: chris rued User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7b) Gecko/20040421 X-Accept-Language: en-us, en, fr MIME-Version: 1.0 To: Thorsten Greiner References: <7FF62A49079FD511B14400065B19EF120550B8A0@cprnt003.satyam.com> <40AE1884.3090206@xsb.com> <20040521164036.GA782@tybalt.greiner.local> In-Reply-To: <20040521164036.GA782@tybalt.greiner.local> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: java@freebsd.org Subject: Re: EX-OR Boolean Operator in Java X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2004 17:54:32 -0000 Thorsten Greiner wrote: >* Christopher Rued [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