#1. What is boxing? What is unboxing?
Boxing: The process of converting a basic type into a wrapper type.
Unboxing: The process of converting a wrapper type into a basic type.
Online learning video sharing: java online tutorial
2. What is the execution process of boxing and unboxing
Boxing is achieved by calling the valueOf
method of the wrapper class;
Unboxing is achieved by calling the xxxValue
method of the wrapper class, xxx
represents the corresponding basic data type.
For example: the valueOf(int)
method of Integer
is automatically called when int is boxed; Integer
is automatically called when unboxing##intValue
method of #Integer.
3. Frequently Asked Questions
(1) Integer packaging classvalueOf When the method returns an object, within the commonly used value range, The cache object will be returned.
valueOf method returns a new object.
valueOf method
BooleanStatic constant of class
TRUE |
FALSE.
Getting started with java development
The above is the detailed content of Boxing and unboxing in java. For more information, please follow other related articles on the PHP Chinese website!