After going through this question, i had one another in my mind.
Question: Why an integer variable value is set to Integer.MAX_VALUE
.
eg.
int x = Integer.MIN_VALUE;
x--;
if (x == Integer.MAX_VALUE) {
System.out.println("Why....");
}
There must be some reason that is why this behavior implemented explicitly, otherwise throwing an Exception
would be a better idea. I could not find/locate this behavior in JLS.