[Java 教學範例拷貝]- 邏輯、位元運算
剛才找資料時發現一個的Java 教學網站,趕快發揮(C/P)的長才將它備份來,有需要的同好,歡迎來(C/P)一下^^。
拷貝來源:
http://openhome.cc/Gossip/JavaGossip-V1/
http://openhome.cc/Gossip/JavaGossip-V1/LogicalBitwiseOperator.htm
public class BitwiseOperator { public static void main(String[] args) { System.out.println("AND運算:"); System.out.println("0 AND 0\t\t" + (0 & 0)); System.out.println("0 AND 1\t\t" + (0 & 1)); System.out.println("1 AND 0\t\t" + (1 & 0)); System.out.println("1 AND 1\t\t" + (1 & 1));
System.out.println("\nOR運算:"); System.out.println("0 OR 0\t\t" + (0 | 0)); System.out.println("0 OR 1\t\t" + (0 | 1)); System.out.println("1 OR 0\t\t" + (1 | 0)); System.out.println("1 OR 1\t\t" + (1 | 1));
System.out.println("\nXOR運算:"); System.out.println("0 XOR 0\t\t" + (0 ^ 0)); System.out.println("0 XOR 1\t\t" + (0 ^ 1)); System.out.println("1 XOR 0\t\t" + (1 ^ 0)); System.out.println("1 XOR 1\t\t" + (1 ^ 1)); } }
|
沒有留言:
張貼留言