The byte data type represents an 8-bit signed two’s complement integer. Byte data type has a minimum value of -128 and a maximum value of 127 (inclusive).
Program to declare and use Java primitive byte variable.
/** * Program to declare and use Java primitive byte variable. * @author W3spoint */ public class DataTypeByteExample { public static void main(String args[]){ //Declare byte type variables. byte b1 = 100; byte b2 = 20; //Print variables value. System.out.println("b1 Value :" + b1); System.out.println("b2 Value :" + b2); } } |
Output:
b1 Value :100 b2 Value :20 |