In this example:
class Test3 {
public static void main(String[] args) {
byte mask = 1;
for(mask <<= 7; mask != 0; mask >>>= 1) {
System.out.print(mask + " ");
}
}
}
I was expecting the output to be -128 64 32 16 8 4 2 1, instead i received an infinite recursive loop of -1. If i change the type of the mask variable to be int, the program behaves normally. Could you please explain me why I am having this particular output? Thank you in advance for your time to help me!