Byte
public class ByteDataType {
public static void main(String[] args) {
System.out.println("byte data type:");
System.out.println("----------------------");
byte a1=1;
byte b1=2;
byte c1=(byte)(a1 + b1); /*type casting required because
value of expression a+b is known only at run time*/
final byte a2=1;
final byte b2=2;
byte c2=(a2+b2); /*type casting not required because
value of expression a+b is known at compile time*/
System.out.println("Sum of a1 and b1= "+c1);
System.out.println("Sum of a2 and b2= "+c2);
}
}
Output:
byte data type:
----------------------
Sum of a1 and b1= 3
Sum of a2 and b2= 3