wood burning stoves*
The moose likes Beginning Java and the fly likes XOR operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "XOR operator" Watch "XOR operator" New topic
Author

XOR operator

podonga poron
Ranch Hand

Joined: May 12, 2008
Posts: 55
class XOR_operator {
public static void main(String[] args) {
System.out.println("xor " + ((true) ^ (true)));
}
}

Result = False ??? WTF .. how this operator works ?

thanks !
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

The "x" in "xor" means "exclusive."

So a^b is true if a is true or b is true, but not if both are true (because then it wouldn't be exclusive).

Or as JLS - 15.22.2 puts it, "the result value is true if the operand values are different; otherwise, the result is false."
[ June 05, 2008: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
podonga poron
Ranch Hand

Joined: May 12, 2008
Posts: 55
thanks ! is clear now
 
Don't get me started about those stupid light bulbs.
 
subject: XOR operator
 
Similar Threads
Dealing with ArrayList items in a static method
swap without using temp variable
WA #1.....word association
XOR operator
Operators