How Can I solve this problem in java ?
int mask = ~0;
System.out.println(Integer.toBinaryString(mask));
When I type this, the output becomes: 11111111111111111111111111111111
However I just want to get 8 bits (11111111).
Another example is,
int left = mask << 7;
System.out.println(Integer.toBinaryString(left));
Output of these two lines is: 11111111111111111111111110000000
How can I take the last 8 bit ? (10000000).
& 0xffto restrict the result to 8 bits?