Java – Byte

Java – Byte 2017-06-13T00:54:43+00:00

Byte class example in java:

The Byte class encapsulates a byte value. It defines the constants MAX_VALUE and MIN_VALUE and provides these constructors:

Byte(byte b)

Byte(String str)

Here, b is a byte value and str is the string equivalent of a byte value.

EX :


 


Output :
b2 = 125
b2 = 126
b2 = 127
b2 = -128
b2 = -127
b2 = -126
b2 = -125
b2 = -124
b2 = -123
b2 = -122
b2 = -121
b1 Object = 120
Minimum Value of Byte = -128
Maximum Value of Byte = 127
b1* 2 = 240
b1* 2 = 240
b3 Object = 120
(b1==b3)? true
(b1.compareTo(b3)? 0

Prev Next