Home > Java > Javagetting Started > Boxing and unboxing in java

Boxing and unboxing in java

王林
Release: 2019-11-28 16:20:36
forward
1954 people have browsed it

Boxing and unboxing in java

#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 class

valueOf When the method returns an object, within the commonly used value range, The cache object will be returned.

(2) Floating-point wrapper class

valueOf method returns a new object.

(3) Boolean wrapper class

valueOf method BooleanStatic constant of class TRUE | FALSE.

More related articles and tutorials are recommended:

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template