---
# System prepended metadata

title: 052 TestBitOP.java

---

# 052 TestBitOP.java
public class TestBitOP {

public static void main(String[] args) {
    // AND運算
    System.out.println(0 & 1);
    System.out.println(0 & 0);
    System.out.println(1 & 0);
    System.out.println(1 & 1);
    System.out.println("===========");
    // OR運算
    System.out.println(0 | 1);
    System.out.println(0 | 0);
    System.out.println(1 | 0);
    System.out.println(1 | 1);
    System.out.println("===========");
    // XOR運算
    System.out.println(0 ^ 1);
    System.out.println(0 ^ 0);
    System.out.println(1 ^ 0);
    System.out.println(1 ^ 1);
    System.out.println("===========");
    // 位元反轉
    System.out.println(~0);
}

}
