Hi, Gene.
It's not a bug, it's known Java behavior. From my RHE, Chapter 2:
For example, byte values can represent a range of -128 to +127, so if two particular bytes have the values 64 and 4 respectively, then multiplying them should, arithmetically, give a value of 256. Actually, when you store the result in a byte variable you will get a value of 0, since only the low-order eight bits of the result can be represented.
So your byte +127 is represented in binary as
01111111
When you add 1 to it, you get
10000000
and this value is equal to -128.
Java throws no exception, or even any indication, when this kind of "rollover" (from high positive values to low negative ones) occurs, so the lesson here is to choose the types of your primitives
wisely.
Art