How many bytes to the centre of the tootsie pop?
Today I ran into an unexpected problem while dealing with InputStreams and OutputStreams...Pop-Quiz
How many times is "World O Hell" printed when the following code is executed?
for(byte i = -128; i <= 127; i++) {
System.out.println("World O Hell");
}
< 256 times
255 times
256 times
> 256 times
Pop-Answer
If you answered > 256 times you're correct. This is because in byte math,
128 + 1 = -127
. It reminds me of the good old days of modular arithmetic in Math 137.