byte

Java's smallest integer primitive type: 8 bits, holding values from -128 to 127.

In more detail

Arithmetic on byte values promotes them to int first, so b = b + 1 does not compile without a cast. Compound assignment such as b += 1 includes an implicit cast back to byte. Overflow wraps around silently.

Example

byte b = 10;
b += 5;      // compiles
// b = b + 5; // does not compile

Related terms

Taught in

References

Certification courses