Hi I need to remove a flag in Java. I have the following constants:
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;
I want to remove, for example OPTION_E from default options. Why is not the following code correct?
// remove option E from defaul options:
int result = DEFATUL_OPTIONS;
result |= ~OPTION_E;