title: How to remove a flag in Java
body: <p>Hi I need to remove a flag in Java. I have the following constants:</p>
  
  <pre><code>public final static int OPTION_A = 0x0001;
  public final static int OPTION_B = 0x0002;
  public final static int OPTION_C = 0x0004;
  public final static int OPTION_D = 0x0008;
  public final static int OPTION_E = 0x0010;
  public final static int DEFAULT_OPTIONS =
         OPTION_A | OPTION_B | OPTION_C | OPTION_D | OPTION_E;
  </code></pre>
  
  <p>I want to remove, for example OPTION_E from default options. Why is not the following code correct?</p>
  
  <pre><code>// remove option E from defaul options:
  int result = DEFATUL_OPTIONS;
  result |= ~OPTION_E;
  </code></pre>