Javatpoint Logo
Javatpoint Logo

Java byte keyword

The Java byte keyword is a primitive data type. It is used to declare variables. It can also be used with methods to return byte value. It can hold an 8-bit signed two's complement integer.

Points to remember

  • The byte range lies between -128 to 127 (inclusive).
  • Its default value is 0.
  • It is useful to handle the st
  • ream of data from a network or file.
  • It is also useful for saving memory in large arrays.
  • It can be used in place of the int data type.
Java byte keyword

Examples of Java byte keyword

Example 1: Using byte with variable

Test it Now


Example 2: byte lies out of range


Java byte keyword

Example 3: Using byte with a method


The age must be: 18
Next TopicJava Case Keyword

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA