89
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
- It is also useful for saving memory in large arrays.
- It can be used in place of the int data type.
ream of data from a network or file.
Examples of Java byte keyword
Example 1: Using byte with variable
Output:
Example 2: byte lies out of range
Output:
Example 3: Using byte with a method
Output:
The age must be: 18
Next TopicJava Case Keyword