1
I saw an example of code on the Java documentation site on bit that can be checked here.
This class belongs to the example cited in link above:
class BitDemo {
public static void main(String[] args) {
int bitmask = 0x000F;
int val = 0x2222;
// prints "2"
System.out.println(val & bitmask);
}
}
My doubt is about how it is possible that the printed value is equal to two?
As if this operation?
I took a calculator and saw that 2222 in hexadecimal corresponds to 8738 and F in hexadecimal equals 15 in decimal.
Based on this, as the expression val & bitmask
results in 2?
Did the answer resolve what was in doubt? Do you need something else to be improved? Do you think it is possible to accept it now?
– Maniero