What is the Byte data type in Java?

Byte is a numeric data type in java. The best choice to use the byte if you want to handle the data in term of streams, either from the file or from the network. It can also be used in place of "int" data type.

  • Size: 1 byte or 8 bits
  • Range: -128 to 127
  • Default Value: 0


byte b=123; (No compile-time error)

byte b =128;(Compile time error:- possible loss of precision fount int, required byte)

byte b=true;(Compile time error :- incompatible error)