public class MainClass { public static void main(String[] argv) { short flags = 20; // 0000 0000 0001 0100 or 0x0014 short mask = 4; // 0000 0000 0000 0100 short rslt = (short) (flags & mask); System.out.println(rslt); } }
4