Public classDemo1 { Public Static voidMain (string[] args) {Booleant =false|true; System.out.println (t); T|=false; System.out.println (t); T= t&false; System.out.println (t); T&=false; System.out.println (t); T= t^true; System.out.println (t); T^=true; System.out.println (t); }
^ Xor operator
True ^ false = True false ^ true = False ^ false = False true ^ true = False
As long as two conditions are true or false at the same time, the result is false.
If there is a scene now, the company needs two programmers, because it takes a man and a woman to take into account the enthusiasm of the work.
Mister in the final audit must probably be like this
if (! (x== male ^y== | | x== (female ^y== )) { Direct pass}
Java use XOR operator ^ for two integers to be exchanged
Scanner in=New Scanner (system.in); int A=in.nextint (); int b=in.nextint (); A=a^B; B=b^A; A=a^B; System.out.println (A+ "" +b);
Many paired occurrences of numbers are saved in the disk file, noting that the paired numbers are not necessarily contiguous, such as 2, 3, 4, 3, 4, 2 ...., because unexpectedly a number disappears, how quickly find out which number disappears
Since a number disappears, there must be a number that appears once and the other numbers appear even several times. It is not necessary to use the search to do, using the two characteristics of the XOR operation--1. Oneself or the result is 0,2. XOR or Satisfaction
Exchange law.
Public Static int findlost (int a[]) { int result=0; for (int i=0;i<a.length;i++) { result^=a[i]; } return
New usages and new realizations of Java operators