如何使用NOT運算符用於在整數JAVA 如何使用NOT運算符用於在整數JAVA
當我把NOT操作它顯示了一個錯誤 包com.learnJava.first(!);
public class LogicalOpTable {
public static void main(String[] args) {
int p,q;
System.out.println("P\t Q\t AND\t OR\t XOR\t NOT\n");
p = 1;
q = 1;
System.out.println(p+ "\t " + q + "\t " + (p&q) + "\t " + (p|q) + "\t " + (p^q) + "\t " + !p);
p = 1;
q = 0;
System.out.println(p + "\t " + q + "\t " + (p&q) + "\t " + (p|q) + "\t " + (p^q) + "\t " + !p);
p = 0;
q = 1;
System.out.println(p + "\t " + q + "\t " + (p&q) + "\t " + (p|q) + "\t " + (p^q) + "\t " + !p);
p = 0;
q = 0;
System.out.println(p + "\t " + q + "\t " + (p&q) + "\t " + (p|q) + "\t " + (p^q) + "\t " + !p);
}
}
的運營商都在JLS和教程解釋。閱讀精細手冊。 –