Converts expressions of primitive type to corresponding expressions of reference type. int intValue = 0; Integer intObject = intValue;bytecode:For Boxing Java compiler uses valueOf() instead of constructor. This is beneficial since it allows for caching, and doesn’t force the creation of a new object on each boxing operation.
Un-Boxing?
Converts expressions of reference type to corresponding expressions of primitive type. Integer intObject = new Integer(0); int intValue = intObject;
bytecode: For Un-Boxing Java compiler uses intValue(), which Returns the value of this Integer as an int.
Recent Comments