Went through this StackOverflow answer explaining how java converts all boolean
, byte
, char
and short
data types into int
.
This does not explain whyin byte b
, b += 1
works but b = b + 1
throws an error, even b = b + (byte)1
and b = (byte)b + (byte)1
throws the same error.