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

Output:

Example 2: byte lies out of range

Output:

Java byte keyword

Example 3: Using byte with a method

Output:

The age must be: 18
Next TopicJava Case Keyword





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA