Campbell Ritchie wrote:Please always say where such questions come from. It looks familiar to me. As you know, 'X' is the same as (char)0x58, which comes to 88 in decimal. The Java® Language Specification should give you that answer. Yes, it does. It tells you how the type of the whole expression depends on its middle and right operands.
Stephan van Hulst wrote:int (and by extension, Integer) wrap around to Integer.MIN_VALUE when they overflow, and Integer.MAX_VALUE when they underflow. Why? Because that's what the language designers decided they should do. It's likely that this behavior carried over from older languages, such as C++.