Byte Datatype Example Java Program


Definition

The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays.

Syntax

byte varibale_name = integer_value;

Byte Datatype Example Program

class ByteDatatype{
	public static void main(String[] args){
		byte a=100;
		byte b=-50;
		System.out.println("The byte is: "+a);
		System.out.println("The byte is: "+b);
	}
}

Sample Output

Output is:
The byte is: 100
The byte is: -50