我试图做一些二进制对象位与比较:不兼容的错误类型Java中
private int selectedButtons = 0x00;
private static final int ABSENCE_BUTTON_SELECTED = 0x01;
private static final int SICKNESS_BUTTON_SELECTED = 0x02;
private static final int LATENESS_BUTTON_SELECTED = 0x04;
这里是比较:
boolean absenceButtonEnabled = selectedButtons & ABSENCE_BUTTON_SELECTED;
但我得到这个错误:
Error:(167, 56) error: incompatible types
required: boolean
found: int
任何想法?
请考虑* Effective Java 2nd Ed的建议*第32项:“使用EnumSet而不是位域”。 –