Ich versuche, eine bitweise UND-Komparator auf einige binäre Objekte zu tun:Inkompatible Typ Fehler, wenn in Java bitshifting
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;
Hier den Komparator:
boolean absenceButtonEnabled = selectedButtons & ABSENCE_BUTTON_SELECTED;
Aber ich bin immer diese Fehler:
Error:(167, 56) error: incompatible types
required: boolean
found: int
Irgendwelche Ideen?
Betrachten Sie den Ratschlag von * Effective Java 2nd Ed * Artikel 32: "Verwenden Sie EnumSet anstelle von Bitfeldern". –