Originally posted by Vad Fogel:
Actually, I missed the condition ++b>0. It exits as soon as b becomes negative.
That's right -- in
Java you'll never get a number overflow exception -- instead (whether good or bad) when you go beyond the upper-limit of a datatype, the numbers just wrap around wihtout any warning. The range of a byte is -128 to 127. So as soon as that loop executes 127 times, it'll wrap around to -128 and the >0 condition will fail.