What is the result of the following code?
public class t1 {
public static void main(String[] args) {
int i=10;
while(i>0){
i = i +1;
if(i==10){
break;
}
}
System.out.println("i=" + i);
}
}
i=-2147483648
because:
01111111 11111111 11111111 11111111
00000000 00000000 00000000 00000000
--------------------------------------------------------------------
10000000 00000000 00000000 00000000
Judging from the sign bit, the highest bit is 1, which is a negative number. Jump out of the judgment in while, and then convert from binary to decimal. The result is i=-2147483648