# ANDing ints in Java [closed]

Is there any better way than doing:

if ((newState & InputState.DEFAULT) == InputState.DEFAULT)


? My InputState.class defines static int variables to the power of 2 that are being ORed with an int to make it possible to determine more than one input state. However, checking the existence of a set bit like this looks just odd to me (and means writing alot of code that is obvious to come anyway) I was wondering whether there is a better solution to that.

• Problem is only that we don't have much to review. Maybe take a look at codereview.stackexchange.com/questions/7594/… – Heslacher Aug 4 '16 at 15:20
• or just use if ((newState & InputState.DEFAULT) != 0) – phuclv Mar 11 '17 at 16:31

public static bool CheckMask(int value, int mask){

if(CheckMask(newState, InputState.DEFAULT))