|Eh, I thought that it would be more easy to load since that I dont need higher numbers.|
1) CPUs work best in their default bit width, typically an integer. Anything else is going to require more work at some point.
2) You're writing in Java, the language whose main selling point was that it wasn't tied to any hardware architecture. Java tries to abstract away the hardware, so do it a favor and stop thinking about the hardware.
3) You're showing signs of the premature optimization anti-pattern. Remember the 40-year-old mantra Premature optimization is the root of all evil.
can you explain whats going on and why I need int.
Not without breaking into binary math, but I'll try.
So you try to add a byte and an int.
Well, they need to be the same type before you can perform arithmetic, so Java converts the byte to an int. This is guaranteed to be safe, because ints are larger than bytes.
Good, now that we have two numbers of the same type (int), we can add them. An int plus an int results in an int.
what do we do with this int? Why, stuff it in a byte, because that's the type left of the equals sign.
Java's byte's range is -128 to 127, but Java's int's range is -2,147,483,648 to 2,147,483,647. That means our int can contain 4,294,967,040 values our byte cannot hold.
The solution? Complain during the compile.
The workaround is to explicitly convert the int to a byte, because adding a byte to a byte is legal without further conversion, and explicitly converting an int to a byte is legal. The smarter workaround is to just use ints, because they're going to spend some portion of their lives as ints anyways.
How To Ask Questions The Smart Way