开发者

Boxing Unboxing in java [duplicate]

开发者 https://www.devze.com 2023-01-21 16:42 出处:网络
This question already has answers here: Closed 12 years ago. Possible Du开发者_JAVA技巧plicates: When to use wrapper class and primitive type
This question already has answers here: Closed 12 years ago.

Possible Du开发者_JAVA技巧plicates:

When to use wrapper class and primitive type

What is boxing and unboxing and what are the trade offs?

Boxing basically converts primitive type to its corresponding reference type. But when do we need Boxing? Whether Wrapper class and Boxing do the same job?


Autoboxing/unboxing is a pure convenience feature that allows you to assign values of a primitive type a reference of a wrapper class and vice versa, with the compiler automatically adding the code to convert between the two.

0

精彩评论

暂无评论...
验证码 换一张
取 消