UN boxing:
- Conversion Object Byte into primitive byte type.
- Byte class is providing instance method byteValue() to perform this conversion.
Conversion logic to perform Unboxing:
/*
class Byte
{
static Byte valueOf(byte b)
Returns a Byte instance representing the specified byte value.
byte byteValue()
Returns the value of this Byte as a byte.
}
*/
class ObjectToPrimitive
{
public static void main(String[] args)
{
byte x = 100;
Byte y = Byte.valueOf(x);
byte z = y.byteValue();
}
}