While studying JAVA, I tried to check the upper limit of the while , which continues to increase int . Please see the following program:
public class Test { public static int a(){ int a = 10; while(a > 9 ) ++a; return a; } public static void main(String[] argc) { Test t = new Test(); int k = ta(); System.out.println("k = "+(1 * k)); } }
I know that the 32-bit range is from -2,147,483,648 to 2,147,483,647, therefore, based on this, I expected the output as 2,147,483,647 , but instead I get:
k = -2147483648
I even tried
System.out.println("k = "+(1 * k/2));
but still the conclusion:
k = -1073741824
Question:
Why is the decision negative when it should be positive?
pulse source share