The addition operation is returning an int. You are trying to assign an int to a byte, which is giving you a warning. You can either switch a's declaration to be an int, or explicity cast all of your additions to byte, essentially telling the compiler you are aware there is a possible loss of precision but you want to do it anyway.
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Joined: Jan 14, 2010
How do i "explicity cast all of your additions to byte" ?
W. Joe Smith
Joined: Feb 10, 2009
You explicitly cast the additions like this:
This is telling the compiler that you are taking the result of your addition, no matter what it is, and changing it to a byte. If any of your additions should go beyond the bounds of a byte, though, you will get unexpected results.
I would suggest doing a Google search for explicit casting in java, as it has many other uses.