What is this expression in Java (1 << 2)?
2 answers
If you want to know why use use 1 << 2
and not 4, which is the same value, it is because you explicitly want to use a bitmask, eg.
public static final int FLAG0 = 1 << 0; public static final int FLAG1 = 1 << 1; public static final int MODIFY_METADATA = 1 << 2;
Indicates that each value is in a bit mask.
+3
source share