title: Why is method1 and method2 the same at the Bytecode level?
body: <p>I wrote this simple <code>Test</code> class to see how Java evaluates <code>boolean</code> algebra at the Bytecode level:</p>
  
  <pre><code>public class Test {
  
      private static boolean a, b;
  
      public static boolean method1(){
          return !(a || b);
      }
  
      public static boolean method2(){
          return !a &amp;&amp; !b;
      }
  }
  </code></pre>
  
  <p>If you simplify <code>method1()</code> using <a href="http://en.wikipedia.org/wiki/De_Morgan&#39;s_laws" rel="nofollow noreferrer">DeMorgan's Laws</a>, you should get <code>method2()</code>. After looking at the Bytecode (using javap -c Test.class), it looks like:</p>
  
  <pre><code>Compiled from "Test.java"
  public class Test {
      public Test();
      Code:
              0: aload_0
      1: invokespecial #1                  // Method java/lang/Object."&lt;init&gt;":
              ()V
      4: return
  
      public static boolean method1();
      Code:
              0: getstatic     #2                  // Field a:Z
              3: ifne          16
              6: getstatic     #3                  // Field b:Z
              9: ifne          16
              12: iconst_1
      13: goto          17
              16: iconst_0
      17: ireturn
  
      public static boolean method2();
      Code:
              0: getstatic     #2                  // Field a:Z
              3: ifne          16
              6: getstatic     #3                  // Field b:Z
              9: ifne          16
              12: iconst_1
      13: goto          17
              16: iconst_0
      17: ireturn
  }
  </code></pre>
  
  <p>So my question is, why is <code>method1()</code> and <code>method2()</code> exactly the same at the Bytecode level?</p>