Why does this cycle run indefinitely?
3 answers
it
for (byte i = 0; i<=255; i++)
- an endless loop, because i
there will always be <= 255
.
As Java is signed, byte
their value can range from -2^8
(-128) to (2^8)-1
(up to 127).
Once i
equals 127, adding one will turn it to -128, which is obviously less than 255
. Thus, this cycle will run forever.
+4
source to share