如何在 Java 中移除标志
嗨,我需要删除Java中的标志。我有以下常量:
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;
例如,我想从默认选项中删除OPTION_E。为什么下面的代码不正确?
// remove option E from defaul options:
int result = DEFATUL_OPTIONS;
result |= ~OPTION_E;