title: how to use NOT operator for integers in JAVA
body: <p>how to use NOT operator for integers in JAVA  <a href="https://i.stack.imgur.com/fi1EY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fi1EY.png" alt="enter image description here"></a></p>
  
  <p>when i put NOT operator (!) it shows an error 
  package com.learnJava.first;</p>
  
  <pre><code>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&amp;q) + "\t " + (p|q) + "\t " + (p^q) + "\t " + !p );
  
          p = 1;
          q = 0;
  
          System.out.println(p + "\t " + q + "\t " + (p&amp;q) + "\t " + (p|q) + "\t " + (p^q) + "\t " + !p);
  
          p = 0;
          q = 1;
  
          System.out.println(p + "\t " + q + "\t " + (p&amp;q) + "\t " + (p|q) + "\t " + (p^q) + "\t " + !p);
  
          p = 0;
          q = 0;
  
          System.out.println(p + "\t " + q + "\t " + (p&amp;q) + "\t " + (p|q) + "\t " + (p^q) + "\t " + !p);
  
  
      }
  
  }
  </code></pre>