+ 1

Why is my simple 3-line displayimg error?

This is the program...it's displaying "possible lossy conversion", now, I knkw that the '+' operator changes byte to int, but it shouldn't br the case here.? https://code.sololearn.com/cTxTDr3kYPfA/?ref=app

22nd Feb 2020, 3:02 PM
Yuvraj Singh
Yuvraj Singh - avatar
2 Réponses
+ 7
Why are we doing a casting in sum, subtracting division and multiplication? First, if you don't know what I mean by casting, let's just say it's this line of code (in the case of addition): byte c = (byte) (a + b); The fundamental reason is that the addition, subtraction, multiplication and division of two bytes returns me an integer; then I have to transform it to save it back to a byte type
22nd Feb 2020, 3:07 PM
Cmurio
Cmurio - avatar